Computer Science, asked by anandhu368, 1 year ago

java pro Graham to check whether a number is Armstrong number or not using bufferedreader

Answers

Answered by Navakris
1

import java.io.BufferedReader;

import java.io.InputStreamReader;

public class Armstrong {

public static void main(String args[]) throws Exception{

 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

 System.out.println("Enter the Number : ");

 String in = br.readLine();

 int n = Integer.parseInt(in);

 System.out.println(n + " is " + isArmstrong(n));

}

public static String isArmstrong(int n){

 int temp = n,sum = 0,rem = 0;

 while(temp > 0){

  rem = temp % 10;

  sum += (rem*rem*rem);

  temp/=10;

 }

 return (sum == n)?"an Armstrong Number":"not an Armstrong Number";

}

}


anandhu368: so much thank you can you please give your number are you a male or female
anandhu368: WhatsApp
Similar questions