java实现订餐系统的方法-创新互联
创新互联www.cdcxhl.cn八线动态BGP香港云服务器提供商,新人活动买多久送多久,划算不套路!
创新互联是一家专注于网站制作、网站设计与策划设计,阜阳网站建设哪家好?创新互联做网站,专注于网站建设10多年,网设计领域的专业建站公司;建站业务涵盖:阜阳等地区。阜阳做网站价格咨询:028-86922220小编给大家分享一下java实现订餐系统的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!
import java.util.Scanner; public class versionAlliance { public static void main(String[] args) { Scanner in = new Scanner(System.in); String[] names=new String[5];//客户姓名 String[] dishes= {"红烧带鱼","鱼香肉丝","时令鲜蔬"};//菜品名称 double[] prices= {38.0,20.0,10.0};//菜品价格 String[] disMegs=new String[5]; int[] praiseNums=new int[3];//点赞数 int times[]=new int[5];//送餐时间 String addresses[]=new String[5];//送餐地址 int[] states=new int[5];//订单状态 double[] sumPrices=new double[5];//订单金额 int chose; int chose1 = 1; do { System.out.println("欢迎使用“吃货联盟订餐系统”"); System.out.println("*****************************"); System.out.println("1.我要订餐"); System.out.println("2.查看餐代"); System.out.println("3.签收订单"); System.out.println("4.删除订单"); System.out.println("5.我要点赞"); System.out.println("6.退出系统"); System.out.println("*****************************"); System.out.print("请选择:"); chose = in.nextInt(); switch(chose) { case 1: System.out.println("*****我要订餐*****"); System.out.print("请输入订餐人姓名:"); for (int i = 0; i < names.length; i++) { if (names[i]==null) { names[i]=in.next(); break; } } System.out.println("序号\t菜名\t单价\t点赞数"); System.out.println("1\t"+dishes[0]+"\t"+prices[0]+"\t"+praiseNums[0]); System.out.println("2\t"+dishes[1]+"\t"+prices[1]+"\t"+praiseNums[1]); System.out.println("3\t"+dishes[2]+"\t"+prices[2]+"\t"+praiseNums[2]); System.out.println("请选择您要点的菜品编号:"); int No=in.nextInt(); String disMeg=null; double price=0; double sumPrice=0; if(No==1) { disMeg=dishes[0]; price=prices[0]; }else if(No==2) { disMeg=dishes[1]; price=prices[1]; }else if(No==3) { disMeg=dishes[2]; price=prices[2]; } System.out.println("请选择您需要的份数:"); int copies=in.nextInt(); System.out.println("请输入送餐时间:"); int time=in.nextInt(); for (int i = 0; i < names.length; i++) { if (times[i]==0) { times[i]=time; break; } } System.out.println("请输入送餐地址:"); for (int i = 0; i < names.length; i++) { if (addresses[i]==null) { addresses[i]=in.next(); break; } } sumPrice=copies*price; for (int i = 0; i < names.length; i++) { if (sumPrices[i]==0) { sumPrices[i]=sumPrice; break; } } for (int i = 0; i < names.length; i++) { if(disMegs[i]==null) { disMegs[i]=disMeg+copies; break; } } for (int i = 0; i < names.length; i++) { if(states[i]==0) { states[i]=1; break; } } System.out.println("订餐成功!"); System.out.println("您订的是:"+disMeg+" "+copies+"份"); System.out.println("送餐时间:"+time+"点"); System.out.println("餐费:"+sumPrice+"元"); System.out.println("输入0返回,其他退出:"); chose1=in.nextInt(); break; case 2: System.out.println("***查看餐袋***"); System.out.println("序号\t订餐人\t餐品信息\t\t送餐时间\t送餐地址\t总金额\t订单状态"); for (int i = 0; i < names.length; i++) { if(names[i]!=null) { String state=(states[i]==1)?"已预订":"已完成"; System.out.println((i+1)+"\t"+names[i]+"\t"+disMegs[i]+"份"+"\t"+times[i] +"点"+"\t"+addresses[i]+"\t"+sumPrices[i]+"\t"+state); } } System.out.println("输入0返回,其他退出:"); chose1=in.nextInt(); break; case 3: System.out.println("***签收订单***"); System.out.println("请选择要签收的订单号:"); int num=in.nextInt(); if(states[num-1]==1) { states[num-1]=2; System.out.println("订单签收成功!"); }else if(states[num-1]==2) { System.out.println("订单已签收!"); }else { System.out.println("无此订单!"); } System.out.println("输入0返回,其他退出:"); chose1=in.nextInt(); break; case 4: System.out.println("***删除订单***"); System.out.println("请输入要删除的订单号:"); int num1=in.nextInt(); if(names[num1-1]!=null&&states[num1-1]==2) { for (int i=num1-1; i < names.length-1; i++) { names[i]=names[i+1]; times[i]=times[i+1]; states[i]=states[i+1]; addresses[i]=addresses[i+1]; sumPrices[i]=sumPrices[i+1]; disMegs[i]=disMegs[i+1]; } System.out.println("订单删除成功!"); }else if(names[num1-1]!=null&&states[num1-1]==1) { System.out.println("订单未签收,不可删除!"); }else if(names[num1-1]==null) { System.out.println("不存在此订单!"); } System.out.println("输入0返回,其他退出:"); chose1=in.nextInt(); break; case 5: System.out.println("***我要点赞***"); System.out.println("序号\t菜名\t单价"); System.out.println(1+"\t"+dishes[0]+"\t"+prices[0]+"\t"+praiseNums[0]+"赞"); System.out.println(2+"\t"+dishes[1]+"\t"+prices[1]+"\t"+praiseNums[1]+"赞"); System.out.println(3+"\t"+dishes[2]+"\t"+prices[2]+"\t"+praiseNums[2]+"赞"); System.out.println("请选择您要点赞的序号:"); int num3=in.nextInt(); switch(num3) { case 1: praiseNums[0]++; System.out.println("点赞成功!"); break; case 2: praiseNums[1]++; System.out.println("点赞成功!"); break; case 3: praiseNums[2]++; System.out.println("点赞成功!"); break; } System.out.println("输入0返回,其他退出:"); chose1=in.nextInt(); break; default: System.out.println("退出系统!"); return; } }while(chose1==0); System.out.println("退出系统!"); } }
网页题目:java实现订餐系统的方法-创新互联
网站地址:http://scyanting.com/article/dhphgp.html