public class Demo8 {
public static void main(String[] args) {
System.out.println("请输入是否是会员:是(y)/否(其他字符)");
Scanner sc = new Scanner(System.in);
int y;
String c = sc.next();
switch (c) {
case "y":
System.out.println("请输入购物金额");
int s = sc.nextInt();
System.out.println("实际支付:" + s * 0.75);
break;
default:
break;
}
}
}
使用嵌套结构实现按折扣进行购物。 嵌套功能再熟悉一下
最新推荐文章于 2024-07-14 09:35:54 发布