我对CS课程的介绍是为了制作一个用户可以输入字母等级的程序,然后使用另一个类的数组创建直方图。程序Z关闭程序,它也会计算错误。我现在意识到我应该写一个命令让用户写信,但是完成了什么,这对于这个程序无关紧要。我相信下面显示的内容有效,但我需要一些帮助来制作第二个类和数组。如果有人可以提供帮助,我会非常感激。
public static void main (String[] args) {
Scanner scan = new Scanner (System.in);
int aCount = 0;
int bCount = 0;
int cCount = 0;
int dCount = 0;
int fCount = 0;
int mCount = 0;
int Tscore = -1;
int count = 0;
String score;
while (Tscore == -1)
{ count ++;
System.out.print("Pleases Enter a Letter Grade or Z to quit");
score = scan.next() ;
if (score.equals("a") || score.equals("A")) {
aCount++ ;
} else if (score.equals("b") || score.equals("B")) {
bCount++ ;
} else if (score.equals("c") || score.equals("C")) {
cCount++ ;
} else if (score.equals("d") || score.equals("D")) {
dCount++ ;
} else if (score.equals("f") || score.equals("F")) {
fCount++ ;
} else if (score != "a" && score != "A" && score != "b" && score != "B" && score != "c" && score != "C" && score != "d" && score != "D" && score != "f" && score != "F" && score != "z" && score != "Z") {
mCount++ ;
} else if (score.equals("z") || score.equals("Z")) {
Tscore++ ;
}