我写了这段代码,但是当我的密码正确时我有问题。请指导我。我是 Java 编码的新手
import java.util.Scanner;
public class PasswordProjectQ {
private static Scanner passwordInput;
public static void main(String[] args) {
passwordInput = new Scanner(System.in);
int builtInPassword = 3720118;
System.out.println("Please enter your password:(just integer)");
if(passwordInput.hasNextInt() && passwordInput.nextInt() != builtInPassword) {
System.out.println("You entered the right format \nbut the password is WRONG!");
}else if(passwordInput.hasNextInt() && passwordInput.nextInt() == builtInPassword) {
System.out.println("Thanks,your password is correct");
}else {
System.out.println("WRONG format!");
}
}
}
郎朗坤
慕码人8056858
随时随地看视频慕课网APP
相关分类