// public class Main{
// public static double add(double a, double b){
// return a + b;
// }
// public static double minus(double a, double b){
// return a - b;
// }
// public static double multiply(double a, double b){
// return a * b;
// }
// public static double divide(double a, double b){
// return a / b;
// }
// public static void main(String args[]){
// System.out.println("4.4加上7.11的结果:" + Main.add(4.4, 7.11));
// System.out.println("8.9减去2.28的结果:" + Main.minus(8.9, 2.28));
// System.out.println("5.2乘以13.14的结果:" + Main.multiply(5.2, 13.14));
// System.out.println("92除以89的结果:" + Main.divide(92, 89));
//
// }
// public class Audience{
// String name;
// int age;
// public Audience(String name, int age){
// this.name = name;
// this.age = age;
// }
// public void buyTicket(){
// if(this.age >= 18){
// System.out.println(name + "\t\t" + age + "\t\t" + 40);
// }
// else{
// System.out.println(name + "\t\t" + age + "\t\t" + 40 / 2);
// }
// }
// public static void main(String args[]){
// System.out.println("姓名\t\t年龄\t\t票价(元)");
// System.out.println("----------------------------------");
// Audience audience1 = new Audience("李明", 20); //李明,20岁
// audience1.buyTicket(); //李明购票
// Audience audience2 = new Audience("钱丽", 16); //钱丽, 16岁
// audience2.buyTicket(); //钱丽购票
// Audience audience3 = new Audience("周刚", 8); //周刚, 8岁
// audience3.buyTicket(); //周刚购票
// Audience audience4 = new Audience("吴红", 32); //吴红,32岁
// audience4.buyTicket(); //吴红购票
// }
// }
public class Student{
int number;
String name;
float chinese;
float math;
float english;
public Student(int number, String name, float chinese, float math, float english){
this.number = number;
this.name = name;
this.chinese = chinese;
this.math = math;
this.english = english;
}
public void average(){
float aver = (chinese + math + english) / 3;
System.out.println(number + "\t" + chinese + "\t" + math + "\t" + english + "\t" + aver);
}
public static void main(String[] args){
System.out.println("学号\t姓名\t语文\t数学\t英语\t平均分");
System.out.println("——————————————————————————————————————————————————");
Student student1 = new Student(1, "张三", 91.5f, 98f, 89f); //张三的各科成绩
student1.average(); //计算张三的平均分
Student student2 = new Student(2, "李四", 96f, 98.5f, 93f); //李四的各科成绩
student2.average(); //计算李四的平均分
Student student3 = new Student(3, "王五", 97f, 100f, 98.5f); //王五的各科成绩
student3.average(); //计算王五的平均分
Student student4 = new Student(4, "钱六", 77f, 83f, 81f); //钱六的各科成绩
student4.average(); //计算钱六的平均分
}
}