1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /*Write a 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"); } } |
ADB commands for Android
Android
What are C Tokens?
C/C++
Least Recently Used Paging Algorithm
Advanced programs
First In First Out Page Replacement Algorithm
Simple programs
Java Program to find the IP address of the Machine
Basic Programs
Palindrome checking using function overloading
Advanced programs
write a java program to create an array of 10 cells, store the values in the area at run time. find the largest and smallest element.
Java program to find whether given no. is Armstrong or not using (if-else statement
)
you’re right java programs can easily be printed using if else
you’re right java programs can easily be printed using if else the coding is at website http://www.fuckjava.com
you are stupid to search on this worst wrong site
Great Post Friend!
I worked on it and make my own logic to create this program. Including its theory and everything want to know about Armstrong number…..
HERE IT IS:
http://www.codenirvana.in/2013/05/what-is-armstrong-number-java-program.html
Can I get the same program without using any functions?
I need simple program without using any function as I am learning java now.
This link can help you …
See this link it would be helpful ..
http://www.techycage.com/2014/12/program-to-chech-wheather-number-is.html
class armstrong
{public static void accept(int no)
{int p=no,rem,s=0;
do
{rem=p%10;
s=s*10+rem;
p=p/10;
}
while(p!=0);
if(s==no)
System.out.println(“it is an armstrong”);
else
System.out.println(“it is not an armstrong”);
}}
what is the error in it could anyone please reply