帮忙看看都有哪些错误

kangwor 2011-04-29 05:40:58
import javax.swing.JOptionPane;
public class testone
{
public static void main(String [] args)
{
int total,gradCounter,gradeValue,average;
String grade;
total=0;
gradeCounter=1;
while(gradeCounter<=10)
{
gradeJOptionPane.showInputDialog("Enter");
gradevalue=Integer.parseInt(grade);
total=total+gradeValue;
gradeCounter=gradeCounter+1;

}
average=total/10;
JOptionPane.showMessageDialog(null,"class average is",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
...全文
41 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
kangwor 2011-05-01
  • 打赏
  • 举报
回复
为什么我们老师给的程序就编译成功了呢?
  • 打赏
  • 举报
回复

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);
}
}
kangwor 2011-04-29
  • 打赏
  • 举报
回复

老师给的程序

50,527

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧