-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_armstrong.java
More file actions
44 lines (42 loc) · 1.15 KB
/
Copy pathJava_armstrong.java
File metadata and controls
44 lines (42 loc) · 1.15 KB
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
39
40
41
42
43
44
import java.util.Scanner;
public class Java_armstrong {
public static void isArmstrong(int inp,int cnt){
int rem;
double res,output=0;
//commenting for extra variable
//new comment
int comp_inp=inp;
do{
rem=inp%10;
res=Math.pow(rem,cnt);
output=output+res;
inp=inp/10;
}
while(inp>0);
int value = (int)output;
if(comp_inp == value){
System.out.println(comp_inp +" is a armstrong number");
}
else{
System.out.println(comp_inp +" is not a armstrong number");
}
}
public static int int_count(int sum){
int cnt_res=0;
while(sum>0){
sum/=10;
cnt_res++;
}
return cnt_res;
//comment
}
public static void main(String args[]){
Scanner obj = new Scanner(System.in);
System.out.println("Enter number to find armstrong number:");
int input = obj.nextInt();
int count = int_count(input);
isArmstrong(input,count);
obj.close();
//System.out.println(count);
}
}