public class GetMaxAndMin {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int number;
int max=0,min=0;
do {
System.out.print("请输入一个整数(输入0结束):");
number = input.nextInt();
if (number == 0) {
break;
}
if ((max < number) || (max == 0)) {
max = number;
}
if ((min > number) || (min == 0)) {
min = number;
}
} while (number!=0);
System.out.printf("最大值是:%d\t最小值是:%d\n", max, min);
}
}
public class Week {
public static void main(String[] args) {
int number=-1;
Scanner input = new Scanner(System.in);
while (number != 0) {
System.out.println("请输入数字1~7(输入0结束)");
number = input.nextInt();
switch (number) {
case 0:
break;
case 1:
System.out.println("今天是 MON");
break;
case 2:
System.out.println("今天是 TUE");
break;
case 3:
System.out.println("今天是 WED");
break;
case 4:
System.out.println("今天是 THU");
break;
case 5:
System.out.println("今天是 FRI");
break;
case 6:
System.out.println("今天是 SAT");
break;
case 7:
System.out.println("今天是 SUN");
break;
default:
System.out.println("请重新输入");
}
}
System.out.println("程序结束!");
}
}
public class AirplaneDiscount {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double price=5000;
int makeAChoice;
double[] discount = new double[2];
while (true) {
System.out.print("请输入您出行的月份:");
makeAChoice= input.nextInt();
if (makeAChoice <= 12 && makeAChoice > 0) {
if (makeAChoice >= 4 && makeAChoice <= 10) {
discount = new double[]{0.9, 0.6};
} else {
discount = new double[]{0.5, 0.4};
}
} else {
System.out.println("输入错误请重新输入");
continue;
}
System.out.print("请问您选择 头等舱还是经济舱?头等舱输入1,经济舱输入2:");
makeAChoice= input.nextInt();
switch (makeAChoice) {
case 1:
case 2:
System.out.println("您的票价为:"+ (price * discount[makeAChoice - 1]));
return;
default:
System.out.println("输入错误请重新输入");
}
}
}
}