forked from ghostmkg/programming-language
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArmstrong.java
More file actions
Latest commit
38 lines (34 loc) · 723 Bytes
/
Copy pathArmstrong.java
File metadata and controls
38 lines (34 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
importjava.util.*;
classArmstrong
{
intarm(intn)
{
intc,s=0;
while(n>0)
{
c=n%10;
s=s+(int)(Math.pow(c,3));
n=n/10;
}
returns;
}
voidrange(intl,intu)
{
inti;
for(i=l;i<=u;i++)
{
if(i==arm(i))
System.out.println(i+" ");
}
}
publicstaticvoidmain()
{
Scannersc=newScanner(System.in);
Armstrongob=newArmstrong();
intlo,up;
System.out.println("Enter the lower and the upper limits");
lo=sc.nextInt();
up=sc.nextInt();
ob.range(lo,up);
}
}