0
我基本上試圖顯示高於平均水平,低於平均水平的成績輸入,並顯示所有成績。正如你在下面看到的,我展示了所有的成績輸入。現在我的問題是如何扭轉所有等級?如何使用以下方法反轉字符串數組?
if (grades.size() != 0) {
double average = (double) total/grades.size();
System.out.println("\nAverage of grades is " + average);
for (int i = 0; i < grades.size(); i++) {
grade = grades.get(i);
count++;
countStr += grade + ", "; //All grades
if (grade > average) {
above++;
aboveStr += grade + ", ";
} else {
below++;
belowStr += grade + ", ";
}
}
System.out.println(above + " grades above average:");
System.out.println(aboveStr);
System.out.println(below + " grades below average:");
System.out.println(belowStr);
System.out.println("All grades: " + countStr);
}
用JavaScript回答到java問題不是一個好主意 – baao