日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > c/c++ >内容正文

c/c++

学校食堂简易点餐管理系统(含用户登录且密码隐藏)C++

發布時間:2023/12/8 c/c++ 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 学校食堂简易点餐管理系统(含用户登录且密码隐藏)C++ 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?系統運行步驟陳述:

  • 運行程序進入用戶登陸界面,輸入賬戶及密碼
  • 如果賬戶以及密碼輸入正確則進入系統,顯示登陸成功
  • 緊接著以下按照指示輸入,所輸入字母不區分大小寫
  • 進入系統后便可看見菜單選項,a,b,c,d,e五類菜及各類菜里面的菜品全稱,編號和單價,以及八種口味及編號
  • 按照提示輸入自己想吃的哪類菜編號
  • 進入該類菜之后輸入想吃菜品的編號
  • 下一步會提示輸入口味,則輸入口味編號
  • 下一步會提示繼續選擇自己想吃的一類菜,繼續的話則根據菜單輸入相關字母,想退出的話直接按'q'或'Q'
  • 則會統計所選菜的總數以及所選各類菜總價格代碼輸出數據見statis.txt文件
  • ?源程序里面的注釋我都給的很詳細,就不在這里一一介紹啦,還是那句老話,寫的很倉促,存在很多問題,希望大家不要見笑哈!下面給出代碼。

    源代碼如下:?

    //ordersystem //author:babysen //date:2022/01/05-07#include <iostream> #include <string> #include <fstream> #include <conio.h>using namespace std;const int strsize = 30; const string flavor[8] = {"三鮮", "甜", "微微辣", "微辣", "麻辣", "中辣", "超辣", "番茄"}; //口味//構造顯示函數: void display_menu(); //顯示菜單 void display_name(); //菜名 void display_preference(); //顯示咸淡口味//void display_sex(); //統計男女生人數 //構建結構體,其中s是性別的另一種表達,s=0,1;0為女性,1為男性struct order {char fullname[strsize]; //菜全名int b; //菜編號int price; //價格 };//輸入結構體數組的內容//熱賣推薦菜單 order hsr[6] ={{"香鍋", 1, 15},{"肉夾饃", 2, 7},{"羊肉泡饃", 3, 24},{"洛陽燴菜", 4, 7},{"砂鍋米線", 5, 7},{"泡面加蛋", 6, 6}};//餃子菜單 order dump[8] ={{"大份大肉蓮菜", 7, 10},{"小份大肉蓮菜", 8, 8},{"大份韭菜雞蛋", 9, 10},{"小份韭菜雞蛋", 10, 8},{"大份大蔥牛肉", 11, 12},{"小份大蔥牛肉", 12, 10},{"大份大蔥羊肉", 13, 12},{"小份大蔥羊肉", 14, 10}};//面食菜單 order noodle[10] ={{"大碗三合一面", 15, 11},{"小碗三合一面", 16, 10},{"大碗二合一面", 17, 10},{"小碗二合一面", 18, 9},{"大碗油潑面", 19, 9},{"小碗油潑面", 20, 8},{"大碗拉條子面", 21, 9},{"小碗拉條子面", 22, 8},{"大碗棍棍面", 23, 9},{"小碗棍棍面", 24, 8}};//米飯菜單 order rice[7] ={{"兩葷兩素", 25, 8},{"一葷三素", 26, 8},{"一葷兩素", 27, 7},{"三樣素菜", 28, 6},{"小炒肉蓋澆飯", 29, 11},{"茄子蓋澆飯", 30, 9},{"番茄雞蛋蓋澆飯", 31, 9}};//特色小吃菜單 order spes[4] ={{"一份油條", 32, 4},{"陜西涼皮", 33, 6},{"豆腐腦", 34, 2},{"葫蘆頭泡饃", 35, 13}};//定義菜單函數 void display_menu() {cout << "-----------------------------------------" << endl;cout << "| 餐廳菜單表 |" << endl;cout << "-----------------------------------------" << endl;cout << "| a.熱賣推薦 |" << endl;cout << "-----------------------------------------" << endl;cout << "| b.餃子 |" << endl;cout << "-----------------------------------------" << endl;cout << "| c.面條 |" << endl;cout << "-----------------------------------------" << endl;cout << "| d.米飯 |" << endl;cout << "-----------------------------------------" << endl;cout << "| e.特色小吃 |" << endl;cout << "-----------------------------------------" << endl;cout << "| q.退出并統計 |" << endl;cout << "-----------------------------------------" << endl; }//定義菜名函數 void display_name() {cout << "a.熱賣推薦菜單如下: " << endl;for (int i = 0; i < 6; i++)cout << "菜名: " << hsr[i].fullname << ","<< "編號: " << hsr[i].b << ","<< "單價: " << hsr[i].price << "元" << endl;cout << "b.餃子: " << endl;for (int i = 0; i < 8; i++)cout << "菜名: " << dump[i].fullname << ","<< "編號: " << dump[i].b << ","<< "單價: " << dump[i].price << "元" << endl;cout << "c.面條: " << endl;for (int i = 0; i < 10; i++)cout << "菜名: " << noodle[i].fullname << ","<< "編號: " << noodle[i].b << ","<< "單價: " << noodle[i].price << "元" << endl;cout << "d.米飯: " << endl;for (int i = 0; i < 7; i++)cout << "菜名: " << rice[i].fullname << ","<< "編號: " << rice[i].b << ","<< "單價: " << rice[i].price << "元" << endl;cout << "e.特色小吃: " << endl;for (int i = 0; i < 4; i++)cout << "菜名: " << spes[i].fullname << ","<< "編號: " << spes[i].b << ","<< "單價: " << spes[i].price << "元" << endl; }//定義個人口味函數 void display_preference() {cout << "--------------------------------------" << endl;cout << "| 1.三鮮, 2.甜, 3.微微辣, 4.微辣 |" << endl;cout << "| 5.麻辣, 6.中辣, 7.超辣, 8.番茄 |" << endl;cout << "--------------------------------------" << endl; }//統計男女生人數函數 /* void display_sex() {for (int i = 0; i < NUM; i++)cout << people[i].fullname << " 's sex is: " << people[i].sex << endl; } *///主函數 int main() {//數據寫入文件ofstream outfile("statis.txt", ios::trunc); //輸出結果存儲在statis文件中if (!outfile){cerr << "打開錯誤!" << endl;exit(1);}//1.初始化,設定賬號和密碼。long int ID = 20220106;int num = 6; //輸入密碼次數//2.建立存儲信息的變量。long int id;//3.完成do-while循環結構中輸入的內容cout << "請輸入賬號: ";cin >> id;int i = 0;//初始化一個空字符串,s是密碼字符串string pwd = "", s = "666666";cout << "請輸入密碼: ";char c;while (true){c = getch();if (c != 13) //如果不是回車,就不斷往string類型的pwd內添加c{pwd = pwd + c;cout << "*";}else{if (pwd == s && id == ID){cout << endl;cout << " 登陸成功 " << endl;cout << "-----------------------------------------" << endl;char ch; //菜種類選擇序號int nn; //口味選擇序號double p0[6]; //a類菜的價錢double p1[8]; //b類菜的價錢double p2[10]; //c類菜的價錢double p3[7]; //d類菜的價錢double p4[4]; //e類菜的價錢long int total[35] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //各菜初始點餐數量 //long int total[]={};cout << "歡迎光臨大學食堂就餐,菜單如下: " << endl;display_menu();cout << endl;display_name();cout << endl;display_preference();cout << "______________________________" << endl;cout << "______________________________" << endl;cout << "請用字母輸入您想吃哪個種類的菜品: " << endl;while (cin >> ch && ch != 'q' && ch != 'Q'){cout << "輸入菜名簡稱" << endl;int bi; //菜編號switch (ch) //case分支大括號可以不要,這里為了方便觀看加上了{case 'a':case 'A':{cin >> bi;if (bi == 1)total[0]++;else if (bi == 2)total[1]++;else if (bi == 3)total[2]++;else if (bi == 4)total[3]++;else if (bi == 5)total[4]++;else if (bi == 6)total[5]++;}break;case 'b':case 'B':{cin >> bi;if (bi == 7)total[6]++;else if (bi == 8)total[7]++;else if (bi == 9)total[8]++;else if (bi == 10)total[9]++;else if (bi == 11)total[10]++;else if (bi == 12)total[11]++;else if (bi == 13)total[12]++;else if (bi == 14)total[13]++;}break;case 'c':case 'C':{cin >> bi;if (bi == 15)total[14]++;else if (bi == 16)total[15]++;else if (bi == 17)total[16]++;else if (bi == 18)total[17]++;else if (bi == 19)total[18]++;else if (bi == 20)total[19]++;else if (bi == 21)total[20]++;else if (bi == 22)total[21]++;else if (bi == 23)total[22]++;else if (bi == 24)total[23]++;}break;case 'd':case 'D':{cin >> bi;if (bi == 25)total[24]++;else if (bi == 26)total[25]++;else if (bi == 27)total[26]++;else if (bi == 28)total[27]++;else if (bi == 29)total[28]++;else if (bi == 30)total[29]++;else if (bi == 31)total[30]++;}break;case 'e':case 'E':{cin >> bi;if (bi == 32)total[31]++;else if (bi == 33)total[32]++;else if (bi == 34)total[33]++;else if (bi == 35)total[34]++;}break;}cout << "輸入口味選項:" << endl;cin >> nn;while (nn != 0){switch (nn){case 1:cout << flavor[0] << endl;break;case 2:cout << flavor[1] << endl;break;case 3:cout << flavor[2] << endl;break;case 4:cout << flavor[3] << endl;break;case 5:cout << flavor[4] << endl;break;case 6:cout << flavor[5] << endl;break;case 7:cout << flavor[6] << endl;break;case 8:cout << flavor[7] << endl;break;default:cout << "選擇錯誤" << endl;}break;}cout << "請繼續用字母輸入您想吃哪個種類的菜品: " << endl;}for (int i = 0; i < 6; i++){p0[i] = total[i] * hsr[i].price;outfile << "a類各菜品點餐數如下: " << endl;outfile << hsr[i].fullname << " " << total[i] << " 份" << endl;outfile << "a類各菜品銷售額如下: " << endl;p0[i] = total[i] * hsr[i].price;outfile << hsr[i].fullname << " " << p0[i] << " 元" << endl;}for (int i = 0; i < 8; i++){outfile << "b類各菜品點餐數如下: " << endl;outfile << dump[i].fullname << " " << total[i + 5] << " 份" << endl;outfile << "b類各菜品銷售額如下: " << endl;p1[i] = total[i + 5] * dump[i].price;outfile << dump[i].fullname << " " << p1[i] << " 元" << endl;}for (int i = 0; i < 10; i++){outfile << "c類各菜品點餐數如下: " << endl;outfile << noodle[i].fullname << " " << total[i + 13] << " 份" << endl;outfile << "c類各菜品銷售額如下: " << endl;p2[i] = total[i + 13] * noodle[i].price;outfile << noodle[i].fullname << " " << p2[i] << " 元" << endl;}for (int i = 0; i < 7; i++){outfile << "d類各菜品點餐數如下: " << endl;outfile << rice[i].fullname << " " << total[i + 23] << " 份" << endl;outfile << "d類各菜品銷售額如下: " << endl;p3[i] = total[i + 23] * rice[i].price;outfile << rice[i].fullname << " " << p3[i] << " 元" << endl;}for (int i = 0; i < 4; i++){outfile << "e類各菜品點餐數如下: " << endl;outfile << spes[i].fullname << " " << total[i + 30] << " 份" << endl;outfile << "e類各菜品銷售額如下: " << endl;p4[i] = total[i + 30] * spes[i].price;outfile << spes[i].fullname << " " << p4[i] << " 元" << endl;}break;}else{if (num == 1){cout << "今日次數已用完!";break;}else{cout << endl;cout << "賬戶或密碼錯誤,還剩余" << --num << "次機會" << endl;cout << "請輸入賬號: ";cin >> id;cout << "請輸入密碼: ";pwd = "";}}}}outfile.close();cout << "處理完畢,請打開文件查看結果!" << endl;void free();system("pause");//請按任意鍵繼續system("cls");//清屏操作return 0; }

    ?結果顯示如下:

    陳述在該系統所存在的問題:

  • 用戶登錄界面不支持注冊以及修改密碼
  • 暫時只能單用戶在一臺機器上使用(技術盲點)
  • 沒有寫出現輸入錯誤的結果,就是很傻瓜式的系統(大家有興趣可以加入條件進行修改)
  • 總結

    以上是生活随笔為你收集整理的学校食堂简易点餐管理系统(含用户登录且密码隐藏)C++的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。