package com.neusoft.xf;
class Student{
private String name;
private String studo;
private float english;
private float math;
private float computer;
public Student(String n,String s,float e,float m,float c){
this.setName(n); //为什么要有这一段?,this.setName()是做什么用的?
this.setStudo(s);
this.setEnglish(e);
this.setMath(m);
this.setComputer(c);
}
public void setName(String n){
name = n;
}
public String getName(){
return name;
}
public void setStudo(String s){
studo = s;
}
public String getStudo(){
return studo;
}
public void setEnglish(float e ){
english =e;
}
public float getEnglish(){
return english;
}
public void setMath(float m){
math = m;
}
public float getMath(){
return math;
}
public void setComputer(float c){
computer = c;
}
public float getComputer(){
return computer;
}
public float sum(){
return math+computer+english;
}
public float avg(){
return (math+english+computer)/3;
}
public float max(){
float max = math;
max=max>computer?max:computer;
max =max>english?max:english;
return max;
}
public float min(){
float min= math;
min = min <computer?min:computer;
min = min <english?min:english;
return min;
}
}
public class Example {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Student stu =null;
stu =new Student("大白菜","666",89.0f,90.0f,120.0f);//这里的方法中的值是人工输入的,为什么是在这输入?
System.out.println("最大值是"+stu.max());
System.out.println("总值"+stu.sum());
System.out.println("均值"+stu.avg());
System.out.println("最小值"+stu.min());
}
}
class Student{
private String name;
private String studo;
private float english;
private float math;
private float computer;
public Student(String n,String s,float e,float m,float c){
this.setName(n); //为什么要有这一段?,this.setName()是做什么用的?
this.setStudo(s);
this.setEnglish(e);
this.setMath(m);
this.setComputer(c);
}
public void setName(String n){
name = n;
}
public String getName(){
return name;
}
public void setStudo(String s){
studo = s;
}
public String getStudo(){
return studo;
}
public void setEnglish(float e ){
english =e;
}
public float getEnglish(){
return english;
}
public void setMath(float m){
math = m;
}
public float getMath(){
return math;
}
public void setComputer(float c){
computer = c;
}
public float getComputer(){
return computer;
}
public float sum(){
return math+computer+english;
}
public float avg(){
return (math+english+computer)/3;
}
public float max(){
float max = math;
max=max>computer?max:computer;
max =max>english?max:english;
return max;
}
public float min(){
float min= math;
min = min <computer?min:computer;
min = min <english?min:english;
return min;
}
}
public class Example {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Student stu =null;
stu =new Student("大白菜","666",89.0f,90.0f,120.0f);//这里的方法中的值是人工输入的,为什么是在这输入?
System.out.println("最大值是"+stu.max());
System.out.println("总值"+stu.sum());
System.out.println("均值"+stu.avg());
System.out.println("最小值"+stu.min());
}
}