// 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(); //吴红购票
}
}