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 */


Write a java program with object that check weather number is Armstrong or not,check whether number is armstrong or not in java,java armstrong number,armstrong number in java,armstrong number in java with object

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 circle in C graphics

Draw a Ring in computer graphics

Comment your views on this Article :)


Thank you for visiting my blog :)


No comments

Comment your views on this article

Powered by Blogger.