//1.break练习,实现购物结账
int num =0;
for(int i=1;i<=5;i++) {
System.out.println("欢迎光临第"+i+"家专卖店");
for(int q=1;q<=3;q++) {
System.out.println("要离开吗(y/n)");
String decision = input.next();
if(decision.equals("y")) {
System.out.println("买了一件衣服");
num++;
if(q==3){
System.out.println("离店结账");
break;
}
}else if(decision.equals("n")){
System.out.println("离店结账");
break;
}
}
}
System.out.println("总共买了"+num+"件衣服");
System.out.println("\n");
//2.打印乘法表
System.out.println("九九乘法表:");
for (int num1= 1; num1<= 9; num1++) {
for (int num2 = 1; num2 <=num1; num2++) {
System.out.print(num2+"*"+num1+"="+(num1*num2)+"\t");
}
System.out.println();
}
版权声明:本文为Shao_lei原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。