public class Switch {标签:case,JAVA,System,break,switc,购买,println,out From: https://www.cnblogs.com/txa2003/p/16953923.html
public static void main(String[] args) {
System.out.println("请输入你想要购买的商品序号");
System.out.println("1:可乐 2:牛奶 3:苹果");
Scanner s1 = new Scanner(System.in);
int a = s1.nextInt();
switch (a){
case 1:
System.out.println("已成功购买可乐");
break;
case 2:
System.out.println("已成功购买牛奶");
break;
case 3:
System.out.println("已成功购买苹果");
break;
default :
System.out.println("你输入的序号不正确");
break;
}
}
}