Computer Science, asked by kanishka7221, 1 year ago

write a program whether a number is Armstrong or not by scanner method..

Answers

Answered by saurabh2001
1
please see the attachment
Attachments:

saurabh2001: plz mark me as brainliest
Answered by stylishtamilachee
1

Answer:

import java.util.Scanner ;

public class Armstrong

{

public static void main (String args[ ] )

{

Scanner sc = new Scanner(System.in) ;

System.out.print("Enter a 3digit number to be checked:") ;

int num= sc.nextInt( ) ;

int check = 0, remainder;

do {

remainder = n % 10 ;

check = check + (int)Math.pow(remainder,3) ;

n = n / 10 ;

} while (n != 0) ;

if (check = = num )

System.out.println(num + "is an Armstrong Number") ;

else

System.out.println(num + "is not a Armstrong Number") ;

}

}

Example output:

Enter a 3 digit number to be checked : 345

345 is not a Armstrong number

Armstrong:

An Armstrong Number is a 3-digit number that is equal to sum of cubes of its individual digits,

Example: 153 is an Armstrong Number as 1³ + 5³ + 3³ = 153

Similar questions