We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 15e1ae9 commit 4f07881Copy full SHA for 4f07881
Others/Armstrong.java
@@ -9,10 +9,10 @@
9
*
10
*/
11
public class Armstrong {
12
+ static Scanner scan;
13
public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
14
- System.out.println("please enter the number");
15
- int n = scan.nextInt();
+ scan = new Scanner(System.in);
+ int n = inputInt("please enter the number");
16
boolean isArmstrong = checkIfANumberIsAmstrongOrNot(n);
17
if (isArmstrong) {
18
System.out.println("the number is armstrong");
@@ -42,6 +42,9 @@ public static boolean checkIfANumberIsAmstrongOrNot(int number) {
42
} else {
43
return false;
44
}
45
-
+ }
46
+ private static int inputInt(String string) {
47
+ System.out.print(string);
48
+ return Integer.parseInt(scan.nextLine());
49
50
0 commit comments