Page 198 - computer science (868) class 11
P. 198
3 {
4 static int n;
5 void input(int num)
6 {
7 n=num;
8 }
9 boolean check_armstrong()
10 {
11 int temp, digits=0, rem=0, sum=0;
12 temp=n;
13 while(temp>0)
14 {
15 temp = temp/10;
16 digits++;
17 }
18 temp = n;
19 while(temp>0)
20 {
21 rem = temp % 10;
22 sum += (Math.pow(rem, digits));
23 temp = temp/10;
24 }
25 if(n==sum)
26 return true;
27 else
28 return false;
29 }
30 void display()
31 {
32 boolean ch=check_armstrong();
33 if(ch)
34 System.out.println(n+" is an Armstrong Number");
35 else
36 System.out.println(n+" is not an Armstrong Number");
196196 Touchpad Computer Science-XI

