抱歉,如果这是一个愚蠢的问题,但我对此完全陌生,只是尝试一下。我的代码卡住了....此后,程序结束,无论选择 1 还是 2。我知道我缺少一些简单的东西....任何输入表示赞赏。我已经复制并粘贴了我认为问题所在的部分。
System.out.println("Is this information correct? Enter 1 if it is correct, and 2 to change");
Scanner inputCorrect = new Scanner(System.in);
int pick = inputCorrect.nextInt();
boolean isCorrect = false;
while (isCorrect = false){
while (!(pick == 1) && (!(pick ==2)))
System.out.println("That is not a valid entry please try again");
if (pick == 1){
isCorrect = true;
}
if (pick == 2){
System.out.println("Enter 1 to change your name, 2 to change your age or 3 to change your gender");
Scanner inputChange = new Scanner(System.in);
int change = inputChange.nextInt();
if (change ==1){
Scanner inputNewName = new Scanner(System.in);
System.out.println("Enter the correct name: ");
String correctedName = inputNewName.next();
you.setName(correctedName);
System.out.println(you);
isCorrect = true;
}
if (change ==2) {
Scanner inputNewAge = new Scanner(System.in);
System.out.println("Enter the correct age: ");
int correctedAge = inputNewAge.nextInt();
you.setAge(correctedAge);
System.out.println(you);
isCorrect = true;
}
if (change == 3) {
Scanner inputNewGender = new Scanner (System.in);
System.out.println("Enter the correct gender: ");
char correctedGender = inputNewGender.next().charAt(0);
you.setGender(correctedGender);
System.out.println(you);
isCorrect = true;
}
}
}