J**a二维数组输出成绩

时间:2014.10.22 发布人:bayogiant

J**a二维数组输出成绩

已解决问题

谷歌bayogiant用户在2014.10.22提交了关于“杜甫J**a二维数组输出成绩”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-07-28T20:44:08。希望大家能够帮助她。

详细问题描述及疑问:期待您的答案,真心佩服你,谢谢 !

希望以下的回答,能够帮助你。

第1个回答

用户名:fana88  

packageclient;

importj**a.awt.GridLayout;

importj**a.awt.event.ActionEvent;

importj**a.awt.event.ActionListener;

importj**ax.swing.JButton;

importj**ax.swing.JComboBox;

importj**ax黄月值声襟.swing.JFrame;

importj**ax.swing.JLabel;

importj**ax.swing.JOptionPane;

im般湖西portj**ax.swi伯视那房料供阻卷ng.JPanel;

publicclassstudentimplementsActionListener{

pri来自vateJFramejf;

privateJPaneljp;

privateJLabelname,course;

privateJC331215问答omboBoxname1,course1;

privateJButtonok;

privatescorethe友五亚培只切积对Score[]=newscore[3];

publicstudent(){

jf=newJFrame();

jp=n波上鱼作了ewJPanel省想农住部苏培止();

name=newJLabel("姓名");

course=newJLabel("科伟终目");

jp.setLayout(newGridLayout(3,2));

S触道七象十犯白tringtheName[]={"大雄","静香","康夫","a厚际翻既话ll"};

StringtheCourse[]={"数学","英语","计算机","all"};

name1=newJComboBox(theName);

course1=newJComboBox(t问巴执拉缺兵容缩志两正heCourse);

ok=newJButton("查询");

ok.addActionListener(this);

jp.add(name);

jp.add(name1);

jp.add(course);

jp.add(course1);

jp.add(ok);

jf.setLayout(newGridLayout(1,1));

jf.add(jp);

jf.setSize(400,150);

jf.setLocationRelativeTo(**ll封居象轴富星责检);

jf.setVisible(true);

jf.setDefaultCloseOper率秋想全案刑呢华身ation(JFrame.EXIT_ON_CLO**);

}

publicvoidinputData()//输临张入**

{

this.theScore[然密翻仅方护试检0]=newscore("大雄",10,12,15);

thi看罗诉高附材它饭鸡s.theScore[1时责海兵升]=newscore("静香",88,98,75);

this过止短.theScore[2]=newscore("康夫",85,75,90);

}

publicstaticvoidmain(String[]args){

studentstu=newstudent();

stu.inputData();

}

@Override

publicvoidactionPerformed(ActionEvente){

//TODOAuto-generatedmethodstub

if(e.getSource()==ok){

Stringcontent="";

if(***.name1.getSelectedIndex()==3)//输出全部人的

{

if(this.course1.getSelectedIndex()==3)//全部分数

{

content+="姓名数学英语计算机\n";

for(inti=0;i<this.theScore.length;i++){

content+=(this.theScore[i].getName()+""

+this.theScore[i].getMath()+""

+this.theScore[i].getEnglish()+""

+this.theScore[i].getComputer()+"\n");

}

JOptionPane.showMessageDialog(**ll,content);

return;

}else{

if(this.course1.getSelectedIndex()==0){

content+="姓名数学\n";

for(inti=0;i<this.theScore.length;i++){

content+=(this.theScore[i].getName()+""

+this.theScore[i].getMath()+"\n");

}

}elseif(this.course1.getSelectedIndex()==1){

content+="姓名英语\n";

for(inti=0;i<this.theScore.length;i++){

content+=(this.theScore[i].getName()+""

+this.theScore[i].getEnglish()+"\n");

}

}else{

content+="姓名计算机\n";

for(inti=0;i<this.theScore.length;i++){

content+=(this.theScore[i].getName()+""

+this.theScore[i].getComputer()+"\n");

}

}

JOptionPane.showMessageDialog(**ll,content);

return;

}

}

//System.out.println("nameindex="+name1.getSelectedIndex()+"courseindex="+course1.getSelectedIndex());

else{

if(this.course1.getSelectedIndex()==3){

content+="姓名数学英语计算机\n";

intindex=***.name1.getSelectedIndex();

content+=(this.theScore[index].getName()+""

+this.theScore[index].getMath()+""

+this.theScore[index].getEnglish()+""

+this.theScore[index].getComputer()+"\n");

JOptionPane.showMessageDialog(**ll,content);

return;

}else{

inti=***.name1.getSelectedIndex();

if(this.course1.getSelectedIndex()==0){

content+="姓名数学\n";

content+=(this.theScore[i].getName()+""

+this.theScore[i].getMath()+"\n");

}elseif(this.course1.getSelectedIndex()==1){

content+="姓名英语\n";

content+=(this.theScore[i].getName()+""

+this.theScore[i].getEnglish()+"\n");

}else{

content+="姓名计算机\n";

content+=(this.theScore[i].getName()+""

+this.theScore[i].getComputer()+"\n");

}

JOptionPane.showMessageDialog(**ll,content);

return;

}

}

}

}

}

classscore{//保存每**的类

privateStringname;

privatefloatMath;

privatefloatEnglish;

privatefloatComputer;

publicStringgetName(){

returnname;

}

publicvoidsetName(Stringname){

***.name=name;

}

publicfloatgetMath(){

returnMath;

}

publicvoidsetMath(floatmath){

Math=math;

}

publicfloatgetEnglish(){

returnEnglish;

}

publicvoidsetEnglish(floatenglish){

English=english;

}

publicfloatgetComputer(){

returnComputer;

}

publicvoidsetComputer(floatcomputer){

Computer=computer;

}

publicscore(Stringname,floatMath,floatEnglish,floatComputer){

***.name=name;

this.Math=Math;

this.English=English;

***.Computer=Computer;

}

}

=================