Write a java program with object that check weather number is Armstrong or not
/* Write a java program with an object that checks whether the number is Armstrong or not */
import java.util.Scanner;
class armst{
public void armstrong(int n){ //int 153
int reverse=0, temp;
int rem;
temp=n; //temp=153
while(n>0)
{
rem=n%10;
reverse=reverse+(rem* rem* rem);
n=n/10;
}
if(temp==reverse){
System.out.println(temp+" is an Armstrong Number");
}
else
{
System.out.println(temp+" is not an Armstrong Number");
}
}
}
public class Question_17{
public static void main(String args[]){
armst arm=new armst();
Scanner scan=new Scanner(System.in);
System.out.print("Enter Value : "); //153
int n=scan.nextInt();
arm.armstrong(n);
}
}
Draw a Ring in computer graphics
Comment your views on this Article :)
No comments
Comment your views on this article