标签:div logs 程序设计基础 str private 英语 com name nbsp
最近JAVA开了面向对象的课程,老师布置了作业,嗯,就是这样,啥作业我不怎么会描述,代码如下,自己做的,代码很不成熟,请谅解!大概就是这样:
class Student { private String stuno; private String name; private float math; private float english; private float computer; /*Student() { }*/ public void StuPer(String stuno,String name) { this.stuno = stuno; this.name = name; } public void stuGrade(float math,float english,float computer) { this.math = math; this.english = english; this.computer = computer; } public void count() { float average = (math + english + computer)/3; System.out.println("平均成绩为:" + average); float sum = (math + english + computer); System.out.println("总成绩为:" + sum); float max = 0; if(math > english) { max = math; } else { max = english; } if(max > computer) { System.out.println("最高成绩为:" + max); } else { System.out.println("最高成绩为:" + computer); } float min = 0; if(math > english) { min = english; } else { min = math; } if(min > computer) { System.out.println("最低成绩为:" + computer); } else { System.out.println("最低成绩为:" + min); } } public void tell() { System.out.println("姓名:" + name + " 学号: " + stuno); System.out.println("数学成绩: " + math + "英语成绩: " + english + "计算机成绩: " + computer); } } class stuInfo { public static void main(String[] args) { Student person = new Student(); person.StuPer("2015025500","张三"); person.stuGrade(50,60,70); person.tell(); person.count(); } }
程序运行结果为:
姓名:张三 学号: 2015025500
数学成绩: 50.0英语成绩: 60.0计算机成绩: 70.0
平均成绩为:60.0
总成绩为:180.0
最高成绩为:70.0
最低成绩为:50.0
标签:div logs 程序设计基础 str private 英语 com name nbsp
原文地址:http://www.cnblogs.com/yuyang-gr/p/6759024.html