/*Program to find whether given no. is Armstrong or not. Example : Input - 153 Output - 1^3 + 5^3 + 3^3 = 153, so it is Armstrong no. */ class Armstrong{ public static void main(String args[]){ int num = Integer.parseInt(args[0]); int n = num; //use to check at last time int check=0,remainder; while(num > 0){ remainder = num % 10; check = check + (int)Math.pow(remainder,3); num = num / 10; } if(check == n) System.out.println(n+" is an Armstrong Number"); else System.out.println(n+" is not a Armstrong Number"); } }
WebRep
Overall rating
import java.io.*; public class Jerry { public static void main(String as[]) throws IOException { int k=Integer.parseInt(as[0]); int n=k; int d=0,s=0; while(n>0) { d=n%10; s=s+(d*d*d); n=n/10; } if(k==s) System.out.println("Armstrong number"); else System.out.println("not Armstrong number"); } }
Yes
One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.
The best way to find out if your Java is up to date is to visit the Java website. You can then check the latest verison number, and compare it to what is already on your computer. You check in your programs and files. You can also choose to update, and if you have the current version it won't do it.
String.valueOf(number);
import java.io.*; public class Jerry { public static void main(String as[]) throws IOException { int k=Integer.parseInt(as[0]); int n=k; int d=0,s=0; while(n>0) { d=n%10; s=s+(d*d*d); n=n/10; } if(k==s) System.out.println("Armstrong number"); else System.out.println("not Armstrong number"); } }
sir , what is perfect no?
Yes
Enter "java -version" into a terminal. If Java is installed, it will tell you the version number. If it is not installed, it will say "command not found."
1 is an Armstrong Number 2 is an Armstrong Number 3 is an Armstrong Number 4 is an Armstrong Number 5 is an Armstrong Number 6 is an Armstrong Number 7 is an Armstrong Number 8 is an Armstrong Number 9 is an Armstrong Number 153 is an Armstrong Number 370 is an Armstrong Number 371 is an Armstrong Number 407 is an Armstrong Number 1634 is an Armstrong Number
Java Development Kits are best found on the Java website. There are a number of programmes that can be downloaded. It is also possible to get Java Development Kit downloads from the Oracle website.
If by system number you mean the version number of the Java language on the client computer, you can useSystem.getProperty("java.version"); .Or, if you want the Java virtual machine version number you can use System.getProperty("java.vm.version"); .Finally, if you want the version number of the operating system, you can use System.getProperty("os.version"); .
Math.sqrt(number) function is used to find the square root of a number.. try it
armstrong number
You can use the Math.sqrt() method.
import java.io.*; class Armstrong { public static void main()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter a number"); int a=Integer.parseInt(in.readLine()); int n1=a,rev=0,d=0; while(a!=0) { d=a%10; rev=rev+d*d*d; a=a/10; } if(rev==n1) System.out.println("It is a armstrong number "); else System.out.println("It is not a armstrong number "); } }
There are a number of sites that list the many uses of Java applications. The official Java website is one of these sites. Alternatively, one may also find this information at the web domain DynamicDrive.