JAVA题求解

 我来答
眉中间有颗红点
2018-06-04 · 超过18用户采纳过TA的回答
知道答主
回答量:54
采纳率:50%
帮助的人:11.1万
展开全部
//学生对象
public class Student {
private double computerScore;
private double sportScore;
private double musicScore;
public double getComputerScore() {
return computerScore;
}
public void setComputerScore(double computerScore) {
this.computerScore = computerScore;
}
public double getSportScore() {
return sportScore;
}
public void setSportScore(double sportScore) {
this.sportScore = sportScore;
}
public double getMusicScore() {
return musicScore;
}
public void setMusicScore(double musicScore) {
this.musicScore = musicScore;
}
public Student(double computerScore, double sportScore, double musicScore) {
super();
this.computerScore = computerScore;
this.sportScore = sportScore;
this.musicScore = musicScore;
}
public Student() {
super();
}

}
//Score文件
public class Score {
public static double getTotalScore(Student student) {
return student.getComputerScore() + student.getSportScore() + student.getMusicScore();
}
public static double getAverage(Student student) {
return (student.getComputerScore() + student.getSportScore() + student.getMusicScore()) / 3;
}
public static double getMaxScope(Student student) {
double computerScore = student.getComputerScore();
double sportScore = student.getSportScore();
double musicScore = student.getMusicScore();
if(computerScore >= sportScore && computerScore >= musicScore) {
return computerScore;
}else if(sportScore >= computerScore && sportScore >= musicScore) {
return sportScore;
}else {
return musicScore;
}
}

public static double getMinScope(Student student) {
double computerScore = student.getComputerScore();
double sportScore = student.getSportScore();
double musicScore = student.getMusicScore();
if(computerScore <= sportScore && computerScore <= musicScore) {
return computerScore;
}else if(sportScore <= computerScore && sportScore <= musicScore) {
return sportScore;
}else {
return musicScore;
}
}

public static void outputTotalScope(Student student) {
double computerScore = student.getComputerScore();
double sportScore = student.getSportScore();
double musicScore = student.getMusicScore();
System.out.println(computerScore+sportScore+musicScore);
}

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("请输入计算机成绩");
double computerScore = scan.nextDouble();
System.out.println("请输入体育成绩");
double sportScore = scan.nextDouble();
System.out.println("请输入音乐成绩");
double musicScore = scan.nextDouble();
System.out.println("开始实例化学生=========");
Student student = new Student(computerScore,sportScore,musicScore);
System.out.println("实例化学生成功====");
scan.close();
/*求总成绩
* */
System.out.println(getTotalScore(student));
/*求平均成绩
* */
System.out.println(getAverage(student));
/*求最大成绩
* */
System.out.println(getMaxScope(student));
/*求最小成绩
* */
System.out.println(getMinScope(student));
/*输入总成绩
* */
outputTotalScope(student);
}
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式