Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  Armstrong.java
Language: JAVA
Code:
import java.util.Scanner;

class Armstrong
{
     public static void main(String args[])
     {
          Scanner sc=new Scanner(System.in);
          System.out.println("Enter A Number");
          int num=sc.nextInt();
          int r,sum=0,x=num;
          while(x!=0)
          {

               r=x%10;
               sum=sum+(r*r*r);
               x=x/10;
          }
          
          if(num==sum)
               System.out.println("Yes It Is An Armstrong Number");
          else
               System.out.println("Not Armstrong Number");
          
                         
          
     }
Comments: