我想把这些程序以Windows用户界面的形式输出该怎么改?请高手帮帮忙吧?谢谢
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
class Score {
private int studentNo;// 学号
private int uscore;// 平时成绩
private int mscore;// 其中成绩
private int etScore;// 期末上机成绩
private int wscore;// 期末笔试成绩
private double tscore;// 总成绩 private double zscore;// 80
private double bscore;// 60
// 构造方法
public Score(int studentNo, int uscore, int mscore, int etScore, int wscore) {
super();
this.studentNo = studentNo;
this.uscore = uscore;
this.mscore = mscore;
this.etScore = etScore;
this.wscore = wscore;
} // 比较两个对象总成绩。
public boolean compare(Score s) {
if (this.getTscore() < s.getTscore()) {
return true;
}
return false;
} // 获取总评成绩
public double getTscore() {
this.tscore = this.uscore*0.1 + this.mscore*0.15 + this.etScore*0.25 + this.wscore*0.5;
return this.tscore;
}
// 统计并输出得分超过80分(含80分)的学生学号及总评成绩。
public double chgbsh(){
if(this.tscore>=80)
System.out.print("超过80分(含80分):"+ "学号"+this.studentNo+"总评成绩"+this.tscore);
return this.zscore;
}
//低于60分(不含60分)的学生学号及总评成绩
public double xylsh(){
if(this.tscore<60)
System.out.print("小于60:"+ "学号"+this.studentNo+"总评成绩"+this.tscore);
return this.bscore;
}
public int getStudentNo() {
return studentNo;
} public int getUscore() {
return uscore;
} public int getMscore() {
return mscore;
} public int getEtScore() {
return etScore;
} public int getWscore() {
return wscore;
}
}//测试类:
//Test 类 //Java code
public class w { /**
* @param args
*/
// 已知某班学生Java程序设计课程各阶段的成绩如下:
// 学号 平时成绩 期中成绩 期末上机 期末笔试
// 101 90 88 87 84
// 102 78 60 70 75
// 103 90 86 91 93
// 104 50 44 36 60
// 105 88 87 90 92
// 106 64 72 70 80
// 107 60 61 55 55
// 108 81 84 83 87
// 请按以下要求编写程序:
// (1) 按总评成绩从高到低输出成绩单。
// (2) 计算并输出全班的平均分。
public static void main(String[] args) {
List<Score> lst = new ArrayList<Score>();// 创建一个专载Score对象的容器。 // 实例化和初始化每一个对象的成绩
Score s1 = new Score(101, 90, 88, 87, 84);
Score s2 = new Score(101, 90, 88, 87, 84);
Score s3 = new Score(103, 90, 86, 91, 93);
Score s4 = new Score(104, 50, 44, 36, 60);
Score s5 = new Score(105, 88, 87, 90, 92);
Score s6 = new Score(106, 64, 72, 70, 80);
Score s7 = new Score(107, 60, 61, 55, 55);
Score s8 = new Score(108, 81, 84, 83, 87); // 加载到容器
lst.add(s1);
lst.add(s2);
lst.add(s3);
lst.add(s4);
lst.add(s5);
lst.add(s6);
lst.add(s7);
lst.add(s8); // 冒泡排序
Score temp = null;
for (int i = 1; i < lst.size(); i++) {
for (int j = 1; j < lst.size() - i - 1; j++) {
if (lst.get(j).compare(lst.get(j + 1))) {
temp = lst.get(j);
lst.set(j, lst.get(j + 1));
lst.set(j + 1, temp);
}
}
} // 打印出按总成绩排序的成绩单
Score score = null;
String str = " ";
double aa,bb,cc=0;
System.out.println(" 学号\t平时成绩\t期中成绩\t期末上机\t期末笔试\t总成绩\t");
for (int i = 1; i < lst.size(); i++) {
score = lst.get(i);
str = score.getStudentNo() + "\t\t" + score.getUscore() + "\t\t\t"
+ score.getMscore() + "\t\t\t" + score.getEtScore() + "\t\t\t"
+ score.getWscore() + "\t\t " + score.getTscore() ;
System.out.println(str);
}
for (int i = 1; i < lst.size(); i++)
{
score = lst.get(i);
bb= score.xylsh();
System.out.println(bb) ;
}
for (int i = 1; i < lst.size(); i++)
{
score = lst.get(i);
aa= score.chgbsh();
System.out.println(aa) ;
}
for (int i = 1; i < lst.size(); i++)
{
cc=cc+lst.get(i).getTscore();
}
System.out.println("全班的平均分:"+cc/8) ;
}
}
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
class Score {
private int studentNo;// 学号
private int uscore;// 平时成绩
private int mscore;// 其中成绩
private int etScore;// 期末上机成绩
private int wscore;// 期末笔试成绩
private double tscore;// 总成绩 private double zscore;// 80
private double bscore;// 60
// 构造方法
public Score(int studentNo, int uscore, int mscore, int etScore, int wscore) {
super();
this.studentNo = studentNo;
this.uscore = uscore;
this.mscore = mscore;
this.etScore = etScore;
this.wscore = wscore;
} // 比较两个对象总成绩。
public boolean compare(Score s) {
if (this.getTscore() < s.getTscore()) {
return true;
}
return false;
} // 获取总评成绩
public double getTscore() {
this.tscore = this.uscore*0.1 + this.mscore*0.15 + this.etScore*0.25 + this.wscore*0.5;
return this.tscore;
}
// 统计并输出得分超过80分(含80分)的学生学号及总评成绩。
public double chgbsh(){
if(this.tscore>=80)
System.out.print("超过80分(含80分):"+ "学号"+this.studentNo+"总评成绩"+this.tscore);
return this.zscore;
}
//低于60分(不含60分)的学生学号及总评成绩
public double xylsh(){
if(this.tscore<60)
System.out.print("小于60:"+ "学号"+this.studentNo+"总评成绩"+this.tscore);
return this.bscore;
}
public int getStudentNo() {
return studentNo;
} public int getUscore() {
return uscore;
} public int getMscore() {
return mscore;
} public int getEtScore() {
return etScore;
} public int getWscore() {
return wscore;
}
}//测试类:
//Test 类 //Java code
public class w { /**
* @param args
*/
// 已知某班学生Java程序设计课程各阶段的成绩如下:
// 学号 平时成绩 期中成绩 期末上机 期末笔试
// 101 90 88 87 84
// 102 78 60 70 75
// 103 90 86 91 93
// 104 50 44 36 60
// 105 88 87 90 92
// 106 64 72 70 80
// 107 60 61 55 55
// 108 81 84 83 87
// 请按以下要求编写程序:
// (1) 按总评成绩从高到低输出成绩单。
// (2) 计算并输出全班的平均分。
public static void main(String[] args) {
List<Score> lst = new ArrayList<Score>();// 创建一个专载Score对象的容器。 // 实例化和初始化每一个对象的成绩
Score s1 = new Score(101, 90, 88, 87, 84);
Score s2 = new Score(101, 90, 88, 87, 84);
Score s3 = new Score(103, 90, 86, 91, 93);
Score s4 = new Score(104, 50, 44, 36, 60);
Score s5 = new Score(105, 88, 87, 90, 92);
Score s6 = new Score(106, 64, 72, 70, 80);
Score s7 = new Score(107, 60, 61, 55, 55);
Score s8 = new Score(108, 81, 84, 83, 87); // 加载到容器
lst.add(s1);
lst.add(s2);
lst.add(s3);
lst.add(s4);
lst.add(s5);
lst.add(s6);
lst.add(s7);
lst.add(s8); // 冒泡排序
Score temp = null;
for (int i = 1; i < lst.size(); i++) {
for (int j = 1; j < lst.size() - i - 1; j++) {
if (lst.get(j).compare(lst.get(j + 1))) {
temp = lst.get(j);
lst.set(j, lst.get(j + 1));
lst.set(j + 1, temp);
}
}
} // 打印出按总成绩排序的成绩单
Score score = null;
String str = " ";
double aa,bb,cc=0;
System.out.println(" 学号\t平时成绩\t期中成绩\t期末上机\t期末笔试\t总成绩\t");
for (int i = 1; i < lst.size(); i++) {
score = lst.get(i);
str = score.getStudentNo() + "\t\t" + score.getUscore() + "\t\t\t"
+ score.getMscore() + "\t\t\t" + score.getEtScore() + "\t\t\t"
+ score.getWscore() + "\t\t " + score.getTscore() ;
System.out.println(str);
}
for (int i = 1; i < lst.size(); i++)
{
score = lst.get(i);
bb= score.xylsh();
System.out.println(bb) ;
}
for (int i = 1; i < lst.size(); i++)
{
score = lst.get(i);
aa= score.chgbsh();
System.out.println(aa) ;
}
for (int i = 1; i < lst.size(); i++)
{
cc=cc+lst.get(i).getTscore();
}
System.out.println("全班的平均分:"+cc/8) ;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货