![吃貨聯(lián)盟訂餐系統(tǒng)_第1頁](http://file3.renrendoc.com/fileroot_temp3/2022-5/7/72de5979-d439-444f-b840-f58e0deafa8b/72de5979-d439-444f-b840-f58e0deafa8b1.gif)
![吃貨聯(lián)盟訂餐系統(tǒng)_第2頁](http://file3.renrendoc.com/fileroot_temp3/2022-5/7/72de5979-d439-444f-b840-f58e0deafa8b/72de5979-d439-444f-b840-f58e0deafa8b2.gif)
![吃貨聯(lián)盟訂餐系統(tǒng)_第3頁](http://file3.renrendoc.com/fileroot_temp3/2022-5/7/72de5979-d439-444f-b840-f58e0deafa8b/72de5979-d439-444f-b840-f58e0deafa8b3.gif)
![吃貨聯(lián)盟訂餐系統(tǒng)_第4頁](http://file3.renrendoc.com/fileroot_temp3/2022-5/7/72de5979-d439-444f-b840-f58e0deafa8b/72de5979-d439-444f-b840-f58e0deafa8b4.gif)
![吃貨聯(lián)盟訂餐系統(tǒng)_第5頁](http://file3.renrendoc.com/fileroot_temp3/2022-5/7/72de5979-d439-444f-b840-f58e0deafa8b/72de5979-d439-444f-b840-f58e0deafa8b5.gif)
下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、package cn.bdqn;import java.util.Scanner;* author 韓強* Date 2017 -03- 09* Discription : Java 基礎通過數(shù)組、選擇結構、循環(huán)等實現(xiàn)吃貨聯(lián)盟訂餐系統(tǒng)。* GongNeng1 、我要訂餐; 2 、查看餐袋;3 、簽收訂單;4 、刪除訂單; 5 、我要點贊; 6 、退出系統(tǒng)。*/public class ChiHuo public static void main(String args ) Scanner sc = new Scanner(System. in );/ 初始化訂餐人姓名數(shù)組String name
2、 = new String4;/ 初始化菜品信息數(shù)組String disMegs = new String4;/ 初始化送餐時間數(shù)組int times = new int 4;/ 初始化送餐地址數(shù)組String address = new String4;/ 初始化訂單狀態(tài)數(shù)組, 0表示已預訂, 1 表示已完成int state = new int 4;/ 初始化訂單的總金額數(shù)組double sumPrice = new double 4;/ 初始化2 個訂單信息name0 =" 張飛 " ;disMegs 0 ="東坡肘子 2 份" ;times 0
3、= 11;address 0 ="屯溪路 193號" ;sumPrice 0 = 98.0;state 0 = 1;name1 =" 張龍 " ;disMegs 1 ="扣三絲 2 份" ;times 1 = 18;address 1 ="天成路 207號" ;sumPrice 1 = 178.0;state 0 = 0;/ 初始化供選擇的菜品信息String disNames = "東坡肘子 " , " 佛跳墻 " ,扣三絲 " ;double price = 4
4、9, 129, 89 ;/ 菜品價格int dianZan = new int 3; / 點贊System. out .println( "" );String n = "0" ;go: do " 歡迎使用 " 吃貨聯(lián)盟訂餐系統(tǒng)"*""1 、我要訂餐")"2 、查看餐袋")"3 、簽收訂單")"4 、刪除定單")"5 、我要點贊")"6 、退出系統(tǒng)")"*"" 請選擇
5、: " );System. out .println( System. out .println( System. out .println( System. out .println( System. out .println( System. out .println( System. out .println( System. out .println( System. out .print( int num = sc .nextInt();switch ( num) case 1: String answer = "y" ;ok: do for ( int
6、 j = 0; j < name. length ; j +) if ( name j = null ) System. out .println( "* 我要訂餐*"System. out .println( "* 菜品信息 *");System. out .println( " 序號 t 名稱 t 價格 t 點贊 " );for ( int i = 0; i < disNames . length ; i +) System. out .println( i + 1) + "t"+ disNames
7、 i + "t"+ price i +"t"+dianZan i );System. out .println(”*");System. out .print( " 請選擇菜單序號:");int index = sc .nextInt(); / 菜單序號軟,直到正確為止菜品序號 " );/ 如果菜單號選擇不對,讓他輸入到手while ( index > 3 | index < 1) System. out .print(" 請選擇 1-3 號index = sc .nextInt();if (
8、 index > 0 && index <= 3) break ;System. out .print( " 請輸入訂餐人姓 名: " );String nameOrder = sc .next(); / 訂 餐人姓名System. out .print( " 請輸入訂餐數(shù)量: ");int numOrder = sc .nextInt(); / 訂 餐數(shù)量doublepriceOrder = price index -1 * numOrder ; / 單價 * 訂餐數(shù)量/ 如果訂餐總額達50元,免費送餐,否則要付 5 元送餐
9、費double rate = ( priceOrder >= 50) ? 0 : 5;/ 總餐費是餐費+運送費double sumPriceOrder = priceOrder + rate ;/ 訂餐信息描述String disMeg = disNames index - 1 + numOrder + " 份" ;System. out .print( " 請輸入訂餐時間: ");int timeOrder = sc .nextInt(); / 訂 餐時間while ( timeOrder < 8 | timeOrder > 20)
10、System. out .print( " 訂餐時間為早 8 點- 晚20點,請重新輸入:" );timeOrder = sc .nextInt();System. out .print( " 請輸入送餐地址:");String addOrder = sc .next();System. out .println( " 訂餐成功! " );/ 顯示訂餐信息" 您定的是:" +" 送餐時間:" +" 餐費是: " +總計: " +System. out .printl
11、n( disMeg );System. out .println( timeOrder + " 點" );System. out .println( priceOrder + ", 運費是: " + rate + sumPriceOrder + " 元" );/ 把訂餐信息保存得到數(shù)組中去name j = nameOrder ;disMegs j = disMeg ;times j = timeOrder ;address j = addOrder ;sumPrice j = sumPriceOrder ; break ; else
12、if ( j = name. length - 1) /找到最后一個,還沒有空位說明已經元素已經滿了System. out .println(" 您的餐袋已滿!");break ok; / 直接跳出do-while循環(huán)System. out .print( " 是否繼續(xù)點餐(y/n):");answer = sc .next(); while ( answer .equals( "y" );break ;case 2: System. out .println("* 查看餐袋 *" );System. out .p
13、rintln(" 序號 t 訂餐人 t 餐品信息 tt 送餐日期 t 送餐地址 tt 訂單狀態(tài) t 總金額 " );for ( int i = 0; i < name. length ; i +) if ( name i != null ) System. out .println( i + 1) +"t"+name i + "t"+ disMegs i + "t" + times i + "t"+ address i + "t"+ state i +"t&q
14、uot;+ sumPrice i ); break ;case 3: System. out .println( "* 簽收訂單 *" );System. out .print( "請選擇要簽收的訂單序號: ");int orderId = sc .nextInt();while ( true ) / 如果輸入的單號超出范圍, 則提示重新輸入if ( orderId < 1 | orderId > name. length ) System. out .print( " 請輸入 1-4 的數(shù)字: ");orderId =
15、sc .nextInt(); else break ;boolean flag = false ; / 默認條件是假,設立 是否找到的標記, false 沒找到, true 找到了for ( int i = 0; i < name. length ; i +) if ( name i != null && state i = 0 &&orderld=i + 1) state i = 1;/找到目標元素,把值修改成1System. out .println("編號"+ (i + 1) +”的定單已簽收成功!");flag = t
16、rue ; / 表示找到了 else if ( name i != null && state i =1 && orderId = i + 1) System. out .println("此訂單已簽收,不能重復簽收!");flag = true ; / 表示找到了if (! flag ) / 當 flag=false時,!flag=ture,if語句執(zhí)行System. out .println("沒有此編號訂單!”);break ;case 4: String answer = "y"do System. ou
17、t .println( "* 刪除訂單 *");System. out .print("請輸入要刪除的訂單號: ')int deleteId = sc .nextInt();while (true ) /如果輸入的單號超由范圍,則提示重新輸入if ( deleteId < 1 | deleteId >name. length ) System. out .print("請輸入 1-4 的數(shù)字:”);deleteId = sc .nextInt(); else break ;boolean flag = false ; / 默認條件是假
18、,設立是否找到的標記, false 沒找到, true 找到了for ( int i = 0; i < name. length ; i +) if ( name i != null && state i = 1&& deleteId = i + 1) flag = true ; / 表示找到了 , 已經簽收,可以刪除/ 把要刪除元素后面的元素向前移一位把要刪除元素覆蓋,然后把最后一位元素設置為 null 或 0for ( int j = deleteId - 1; j <name. length - 1; j +) name j = name j
19、+ 1;disMegs j = disMegs j + 1;times j = times j + 1;address j = address j + 1;sumPrice j = sumPrice j + 1; state j = state j + 1;name name. length - 1 = null ;disMegs name. length - 1 =null ;times name. length - 1 = 0;address name. length - 1 =null ;state name. length - 1 = 0;sumPrice name. length -
20、 1 = 0;System. out .println( " 刪除訂單成功!");break ; else if ( name i != null && state i =0 && deleteld = i + 1) flag = true ; /表示找到了,沒有簽收, 不能刪除System. out .println("訂單沒有簽收,不能刪除!”);break ;if (! flag ) / 當 flag=false時,用ag=ture,if語句就行System. out .println( "您要刪除的訂單不存在!&q
21、uot;);System. out .print("是否繼續(xù)刪除(y/n):");answer = sc.next(); while ( answer .equals( "y"); break ;case 5: String answer = "y" do System. out .println(System. out .println( 品彳言息*");System. out .println( 點贊");for ( int i = 0; i <"*我要點贊*"”*);菜”序號t名稱t價格tdisNames . length ; i +)System. out .println( i + 1) +"t"+disNames i + "t"+ price i + "t"+ dianZan i );System. out .println(”*");System. out .print( " 請選擇要
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年度可再生能源并網合同范本
- 金華浙江金華永康市環(huán)境衛(wèi)生管理處工作人員招聘筆試歷年參考題庫附帶答案詳解
- 西安2025年陜西西安音樂學院專任教師招聘20人筆試歷年參考題庫附帶答案詳解
- 舟山2025年浙江舟山市定海區(qū)昌國街道招聘公益性崗位筆試歷年參考題庫附帶答案詳解
- 八年級上學期1月期末語文試題(PDF版無答案)-3
- 漯河2024年河南漯河西城區(qū)現(xiàn)代服務業(yè)開發(fā)區(qū)工作委員會人才引進筆試歷年參考題庫附帶答案詳解
- 溫州浙江溫州平陽縣科學技術局招聘編外工作人員筆試歷年參考題庫附帶答案詳解
- 溫州2025年浙江溫州永嘉縣人民醫(yī)院醫(yī)共體永嘉縣婦幼保健院招聘(一)筆試歷年參考題庫附帶答案詳解
- 泉州2025年福建南安市衛(wèi)生事業(yè)單位招聘編制內衛(wèi)生類工作人員51人筆試歷年參考題庫附帶答案詳解
- 普洱2025年云南普洱第二中學招聘編外教學人員筆試歷年參考題庫附帶答案詳解
- 金點子活動總結匯報
- 原料驗收標準知識培訓課件
- 江蘇春節(jié)風俗 南京夫子廟、鹽水鴨與昆曲
- Unit4MyfamilyStorytime(課件)人教新起點英語三年級下冊
- 《麥田怪圈探密》課件
- 物流運作管理-需求預測
- 《電機與電氣控制(第三版)習題冊》 習題答案
- 鋼桁梁頂推施工方案
- 醫(yī)療器械采購方案投標方案(完整技術標)
- 交通運輸安全工作調研報告
- 旅行社導游合同
評論
0/150
提交評論