50,527
社区成员
发帖
与我相关
我的任务
分享
import javax.swing.JOptionPane;
public class testone {
public static void main(String[] args) {
int total, gradeCounter, gradeValue, average;
String grade;
total = 0;
gradeCounter = 1;
while (gradeCounter <= 10) {
try {
grade = JOptionPane.showInputDialog("Enter");
gradeValue = Integer.parseInt(grade);
total = total + gradeValue;
gradeCounter = gradeCounter + 1;
} catch (Exception e) {
}
}
average = total / 10;
JOptionPane.showMessageDialog(null, "average is" + average,
"class average", JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}