路过的看看哦哦
package cn.Happ.day5;
import java.util.Scanner;
public class Huass {
public static void main(String[] args) {
// TODO Auto-generated method stub
String name="T恤";//商品名称
double price=0.0;//商品价格
int goodsNo=0;//商品编码
System.out.println("MyShopping管理系统>购物结算\n");
//商品清单
System.out.println("********************");
System.out.println("1.T恤 2.网球鞋 3.网球拍");
System.out.println("********************");
Scanner input =new Scanner(System.in);
String answer="y";//标识是否继续
while("y".equals(answer)){
System.out.println("请输入商品编码:");
goodsNo=input.nextInt();
switch(goodsNo){
case 1:
name="T恤";
price=245.0;
break;
case 2:
name="网球鞋";
price=570.0;
break;
case 3:
name="网球鞋";
price=320.0;
break;
}
System.out.println(name+"\t"+"¥"+price+"\n");
System.out.println("是否继续(y/n)");
answer=input.next();
}
System.out.println("程序结束!");
}
}