【发布时间】:2015-09-13 00:01:14
【问题描述】:
我正在制定一个平均成绩的计划。出于某种原因,我的扫描仪或控制台不允许我输入第三个问题的答案,我不知道为什么。
很多代码被注释掉了,因为它现在不需要。
编辑:我不知道如何在这里给代码行编号,但我认为第 23-28 行是问题
import java.text.DecimalFormat;
import java.util.Scanner;
public class GradeData {
public static void main(String[] args) {
int count = 0;
double grade = 0;
//decided to use double for grade in case user's want to be specific with
//decimal points.
String user;
boolean enter;
String name;
String enterAgain;
Scanner userInput = new Scanner(System.in);
System.out.println("Please enter your name: ");
name = userInput.nextLine();
System.out.println("Please enter a grade: ");
grade = userInput.nextDouble();
//System.out.println(user); //May not need this line
System.out.println("Would you like to continue entering grades? (y/n)");
enterAgain = userInput.nextLine();
if (enterAgain.equalsIgnoreCase("y"))
/*|| enterAgain.equalsIgnoreCase("Yes"))*/ {
System.out.println("Please enter another grade: "); }
/* if (user.getScore() > highScore) {
highScore = user.getScore();
}
System.out.println("High Score: "
+ DecimalFormat.format(grade));
user.setScore(0);
}*/
else {
enter = false;
userInput.close();
}
}
}
【问题讨论】: