37 lines
		
	
	
		
			No EOL
		
	
	
		
			799 B
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			No EOL
		
	
	
		
			799 B
		
	
	
	
		
			Java
		
	
	
	
	
	
import java.util.Scanner;
 | 
						|
import java.lang.Math;
 | 
						|
 | 
						|
class Armstrong{
 | 
						|
    public static void main(String args[]){
 | 
						|
        Scanner sc = new Scanner(System.in);
 | 
						|
 | 
						|
        int a,b,digit;
 | 
						|
        int digisum=0;
 | 
						|
        int c=0;
 | 
						|
 | 
						|
        System.out.println("Enter the number you went to check for Armstrong-ness:");
 | 
						|
        a = sc.nextInt();
 | 
						|
    
 | 
						|
        b = a;
 | 
						|
 | 
						|
        while(b!=0){
 | 
						|
            c++;
 | 
						|
            b/=10;
 | 
						|
        }
 | 
						|
 | 
						|
        b = a;
 | 
						|
 | 
						|
        while(b!=0){
 | 
						|
            digit = b%10;
 | 
						|
            digisum += Math.pow(digit, c);
 | 
						|
            b /= 10;
 | 
						|
        }
 | 
						|
 | 
						|
        if(digisum == a){
 | 
						|
            System.out.println("The number is an armstrong number.");
 | 
						|
        }else{
 | 
						|
            System.out.println("The number is not an armstrong number.");
 | 
						|
        }
 | 
						|
 | 
						|
    }
 | 
						|
} |