Page 243 - Cs_withBlue_J_C11_Flipbook
P. 243
8 }
9
10 void input()
11 {
12 Scanner sc=new Scanner(System.in);
13 System.out.println("Enter a number : ");
14 n=sc.nextInt();
15 }
16 boolean check_armstrong()
17 {
18 int temp, digits=0, rem=0, sum=0;
19 temp=n;
20 while(temp>0)
21 {
22 temp = temp/10;
23 digits++;
24 }
25 temp = n;
26 while(temp>0)
27 {
28 rem = temp % 10;
29 sum += (Math.pow(rem, digits));
30 temp = temp/10;
31 }
32 if(n==sum)
33 return true;
34 else
35 return false;
36 }
37
38 void display()
39 {
40 boolean ch=check_armstrong();
41 if(ch)
241
Methods and Constructors 241

