How to find Armstrong Number in java Using by Scanner - LearnHowToCode SarkariResult.com Interview Questions and Answers LearnHowToCodeOnline
How to find Armstrong Number in java Using by Scanner

How to find Armstrong Number in java Using by Scanner

  • Since 153 = 1*1*1 + 5*5*5 + 3*3*3. So 153 is an Armstrong number
  • Since 12 is not equal to 1*1*1+2*2*2. So 12 is not an Armstrong number

//Here start Example for armstronNumber have or not
 
// Using by Scanner 

 import java.util.Scanner;
public class ArmstrongNumber
{
    public static void main(String args[])
    {
        int n, nu, num=0, rem;
        Scanner scan = new Scanner(System.in);
  
        System.out.print("Enter any Positive Number : ");
        n = scan.nextInt();
  
        nu = n;
  
        while(nu != 0)
        {
            rem = nu%10;
            num = num + rem*rem*rem;
            nu = nu/10;
        }
        if(num == n)
        {
            System.out.print("Armstrong Number");
        }
        else
        {
            System.out.print("Not an Armstrong Number");
        }
    }
}


About EasyToCode

I'm Ethan Mariano a software engineer by profession and reader/writter by passion.I have good understanding and knowledge of AngularJS, Database, javascript, web development, digital marketing and exploring other technologies related to Software development.

0 comments:

Featured post

Political Full Forms List

Acronym Full Form MLA Member of Legislative Assembly RSS Really Simple Syndication, Rashtriya Swayamsevak Sangh UNESCO United Nations E...

Powered by Blogger.