import javax.swing.JOptionPane;public class Student { String xh,name; int yy,math,yw,total; Student(String xh1,String name1){ xh=xh1; name=name1; } Student(String xh1,String name1,int yy1,int math1,int yw1){ xh=xh1; name=name1; yy=yy1; math=math1; yw=yw1; } public void display(){ String str=JOptionPane.showInputDialog("請(qǐng)輸入英語成績:"); yy=Integer.parseInt(str); str=JOptionPane.showInputDialog("請(qǐng)輸入數(shù)學(xué)成績:"); math=Integer.parseInt(str); str=JOptionPane.showInputDialog("請(qǐng)輸入語文成績:"); yw=Integer.parseInt(str); JOptionPane.showMessageDialog(null,"學(xué)號(hào):"+xh+"\n姓名:"+name+"\n數(shù)學(xué):"+math+"\n英語:"+yy+"\n語文:"+yw+"\n總成績"+total); } public void sum(){ total=yy+yw+math; } public static void main(String[] args) { Student t1=new Student("xxx", "xxx"); t1.display(); } }
添加回答
舉報(bào)
0/150
提交
取消