import java.util.Scanner;
public class Test {
public static void main(String[] args) {
//创建一个学生对象
Student s = new Student();
//创建一个学生成绩对象
StudentScore sc = new StudentScore();
//从控制台接收学生成绩
Scanner input = new Scanner(System.in);
//提示用户输入学生成绩
System.out.println("please enter three score");
//定义控制台输入的参数
s.Java = input.nextInt();
s.SQL = input.nextInt();
s.English = input.nextInt();
//调用方法
System.out.println("该同学的平均成绩为:" + sc.calcAvg(s));
}
}
public class Student {
//定义一个学生类
int Java;
int SQL;
int English;
}
public class StudentScore {
//定义一个学生的平均成绩
public double calcAvg(Student s1) {
double avg = 0;
avg = (s1.Java + s1.SQL + s1.English) / 3.0;
return avg;
}
}