Posts

Showing posts from June, 2014

To Find out whether a number is Armstrong number

  Armstrong number  is a number that is the sum of its own digits each raised to the power of the number of digits. Let us Look at how to find out whether the number is Armstrong using java. Note: The input is saved in Text file. Input: 7 181 153 Output: True False True import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.File; public class Armstrong {     public static void main (String[] args)  throws FileNotFoundException,NumberFormatException{          File file = new File(args[0]);     BufferedReader in = new BufferedReader(new FileReader(file));    int len;    String currentline;                                 double num;                                 int y;                                 int sum = 0;                                 char z;    try     {          while ((currentline = in.readLine()) != null)        {