recommand scanner method
This commit is contained in:
parent
15e1ae9429
commit
4f07881c42
@ -9,10 +9,10 @@ import java.util.Scanner;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Armstrong {
|
public class Armstrong {
|
||||||
|
static Scanner scan;
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Scanner scan = new Scanner(System.in);
|
scan = new Scanner(System.in);
|
||||||
System.out.println("please enter the number");
|
int n = inputInt("please enter the number");
|
||||||
int n = scan.nextInt();
|
|
||||||
boolean isArmstrong = checkIfANumberIsAmstrongOrNot(n);
|
boolean isArmstrong = checkIfANumberIsAmstrongOrNot(n);
|
||||||
if (isArmstrong) {
|
if (isArmstrong) {
|
||||||
System.out.println("the number is armstrong");
|
System.out.println("the number is armstrong");
|
||||||
@ -42,6 +42,9 @@ public class Armstrong {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
private static int inputInt(String string) {
|
||||||
|
System.out.print(string);
|
||||||
|
return Integer.parseInt(scan.nextLine());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user