創(chuàng)新互聯(lián)www.cdcxhl.cn八線動態(tài)BGP香港云服務(wù)器提供商,新人活動買多久送多久,劃算不套路!
創(chuàng)新互聯(lián)是一家專注于網(wǎng)站制作、網(wǎng)站設(shè)計與策劃設(shè)計,阜陽網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設(shè)10多年,網(wǎng)設(shè)計領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:阜陽等地區(qū)。阜陽做網(wǎng)站價格咨詢:028-86922220小編給大家分享一下java實現(xiàn)訂餐系統(tǒng)的方法,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!
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];//點贊數(shù) int times[]=new int[5];//送餐時間 String addresses[]=new String[5];//送餐地址 int[] states=new int[5];//訂單狀態(tài) double[] sumPrices=new double[5];//訂單金額 int chose; int chose1 = 1; do { System.out.println("歡迎使用“吃貨聯(lián)盟訂餐系統(tǒng)”"); 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.退出系統(tǒng)"); 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點贊數(shù)"); 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("請選擇您需要的份數(shù):"); 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訂單狀態(tài)"); for (int i = 0; i < names.length; i++) { if(names[i]!=null) { String state=(states[i]==1)?"已預(yù)訂":"已完成"; 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("退出系統(tǒng)!"); return; } }while(chose1==0); System.out.println("退出系統(tǒng)!"); } }