answersLogoWhite

0

To find Armstrong number in java?

Updated: 8/11/2023
User Avatar

Wiki User

15y ago

Best Answer

/*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"); } }

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

WebRep

Overall rating

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: To find Armstrong number in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a java program to check a number is Armstrong 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"); } }


To find strong number in java?

sir , what is perfect no?


Can you get a Java program to find the cube of a number?

Yes


How do you find out whether Java is installed on Linux?

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."


List all Armstrong numbers between 1 to 5000?

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


Where can one find a Java development kit?

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.


How do you find a system number in a JAVA program?

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"); .


Which math function is used to find the square root of a number using java?

Math.sqrt(number) function is used to find the square root of a number.. try it


Flow chart for Armstrong number?

armstrong number


How do you write a java program to find the square root of a number?

You can use the Math.sqrt() method.


How do you write a Java program to see whether a number is Armstrong or not... using Buffered Reader and stuff ....?

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 "); } }


Where can one find an array of different java application uses?

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.