编写点餐管理系统

编写点餐管理系统,第1张



import java.util.*;

public class Test {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Map HeatMap=new HashMap();
		Map ColdMap=new HashMap();
		Map DrinkMap=new HashMap();
		HeatMap.put("蚂蚁上树", "23");
		HeatMap.put("鲤鱼打挺", "39");
		HeatMap.put("尖椒肥肠", "36");
		ColdMap.put("拍黄瓜", "15");
		ColdMap.put("油炸花生米", "21");
		DrinkMap.put("可口可乐", "3");
		DrinkMap.put("百事可乐","2.5");
		System.out.println("\t======欢迎来到重庆酒家======");
		boolean b=true;
		double total=0;
		Map map=new HashMap();
		while(b) {
			System.out.println("请输入您需要什么?\n"+"1.热菜\t2.凉菜\t3.饮料\t4.点好了,退出!");
			Scanner in=new Scanner(System.in);
			int i=in.nextInt();
			switch(i) {
			case 1:
		System.out.println("热菜:"+HeatMap.keySet());
		System.out.println("您需要哪个热菜?\n"+"1.蚂蚁上树\t2.鲤鱼打挺\t3.尖椒肥肠");
		int r=in.nextInt();
		if(r==1) {
			map.put("蚂蚁上树", "23");
			total=total+23;
		}else if(r==2) {
			map.put("鲤鱼打挺", "39");
			total=total+39;
		}else if(r==3) {
			map.put("尖椒肥肠", "36");
			total=total+36;
		}
		 break;
			case 2:
		System.out.println("凉菜:"+ColdMap.keySet());
		System.out.println("您需要哪个凉菜?\n"+"1.拍黄瓜\t2.油炸花生米");
		int l=in.nextInt();
		if(l==1) {
			map.put("拍黄瓜", "15");
			total=total+15;
		}else if(l==2) {
			map.put("油炸花生米", "21");
			total=total+21;
		}
		
		break;
			case 3:
		System.out.println("饮料:"+DrinkMap.keySet());
		System.out.println("您需要哪个饮料?\n"+"1.可口可乐\t2.百事可乐");
		int y=in.nextInt();
		if(y==1) {
			map.put("可口可乐", "3");
			total=total+3;
		}else if(y==2) {
			map.put("百事可乐", "2.5");
			total=total+2.5;
		}
		break;
			case 4:
				b=false;
				break;
		default:System.out.println("您输入的有误请重新输入");
			}
			System.out.println("您现在已经点了");
			Set entrySet=map.entrySet();
			Iterator it=entrySet.iterator();
			while(it.hasNext()) {
				Map.Entry entry=(Map.Entry)(it.next());
				Object key=entry.getKey();
				Object value =entry.getValue();
				System.out.println(key+":"+value);
			}
		}
		System.out.println("您总计消费"+total+"元,请支付...");
		try {
			Thread.sleep(5000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("支付成功祝您用餐愉快");
	}

}

 

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/795535.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-06
下一篇 2022-05-06

发表评论

登录后才能评论

评论列表(0条)

保存