# include & lt string & gt
# include & ltiomanip & gt
# include & ltvector & gt
Use namespace std
Structured food
Int number;
String name;
Double the price;
};
Structural order {
Food food;
int pno
int fno
Double the price;
};
Food Allfood[ 10] = {{0, "shredded pork with fish flavor", 7.5}, {1, "moo Shu pork", 8.5}, {2, "kung pao chicken", 6.5}, {3, "shredded potatoes with hot and sour taste", 5.
{4, Sweet and Sour Fillet, 9.0}, {5, Scrambled Eggs with Tomatoes, 6.0}, {6, Braised Eggplant in Oil, 6.5},
{7, "roast chicken with potatoes", 8.0}, {8, "potato beef", 9.0}, {9, "braised pork", 10.0}
};
Vector & lt orders & gt orders;
void addorder(){
bool flag = true
while(flag){
int id,pno,fno
Cout & lt& lt "Please enter the number of dishes, the number of people ordering and the order quantity in turn, separated by spaces: \ n";
CIN & gt; & gtid & gt& gtpno & gt& gtfno
Order items;
item . food . no = id;
item.food.name = Allfood[id]。 Name;
item.food.price = Allfood[id]。 Price;
item.pno = pno
item.fno = fno
Item.payprice = fno*(Allfood[id]. price);
order . push _ back(item);
Char selection;
Cout & lt& lt "Continue to supplement? Y Continue, others exit: \ n ";;
CIN & gt; & gt selection;
Switch (Select) {
Case "y": break;
case“n”:flag = false; Break;
Default value: flag = false to break;
}
}
cout & lt& lt”\ n”;
}
Void browse () {
Vector & lt order & gt* iterator itor = order.begin ();
Cout & lt< "\ nAll orders are as follows: \ n";
Cout & lt& lt OrderNo. \ tFood number, food name, food price, number of people ordering food, order quantity and amount payable \ n ";;
for(int I = 0; Ito! = order . end(); i++,itor++){
cout & lt& ltI+ 1 & lt; & lt\ t ' & lt& ltitor->; food.no & lt& ltsetw( 19)& lt; & ltitor->; food.name & lt& ltsetw( 10)& lt; & ltitor->; food.price<& ltsetw( 10)& lt; & ltitor->; pno & lt& ltsetw( 12)& lt; & ltitor->; fno & lt& ltsetw( 15)& lt; & ltitor->; Payment price & lt& ltendl
}
cout & lt& lt”\ n”;
}
Void query () {
Cout & lt& lt "Please enter the object you want to query: \ n";
cout & lt& lt" 1.\ n ";
cout & lt& lt\ n ';
}
Invalid count () {
bool flag = true
while(flag){
Cout & lt& lt "Please enter the name of the food you want to count: \ n";
String name;
CIN & gt; & gt name;
Double total = 0;
Vector & lt order & gt* iterator itor = order.begin ();
for(int I = 0; Ito! = order . end(); i++,itor++){
if(itor-& gt; total+= itor-& gt; Pay the price;
}
The total order amount of cout & lt& lt name & lt& lt "is:"
Char selection;
Cout & lt& lt "Do you need to continue statistics? Y Continue, others exit: \ n ";;
CIN & gt; & gt selection;
Switch (Select) {
Case "y": break;
case“n”:flag = false; Break;
Default value: flag = false to break;
}
}
cout & lt& lt\ n ';
}
int main(){
while(true){
Cout & lt& lt“* * * * * * * * * * * * Food and Beverage Management Procedure * * * * * * * *”<<;; endl
Cout & lt& lt" 1. Add: \ n ";;
Cout & lt& lt"2. Browse: \ n ";;
Cout & lt& lt"3. Query: \ n ";;
Cout & lt& lt"4. Statistics: \ n ";;
Cout & lt& lt"5. Exit \ n ";;
Int selection;
Cout & lt& lt "Please enter the function number you need: \ n";
CIN & gt; & gt selection;
Switch (Select) {
Case1:addorder (); Break;
Case 2: browse (); Break;
Case 3: query (); Break;
Case 4: count (); Break;
Situation 5: Export (0);
Default value: cout & lt& lt "Wrong function number! \ n ";
Cout & lt& lt "Please re-enter: \ n"; Break;
}
}
Returns 0;
}
The query function is too unclear. I don't know what function it provides, so I didn't write it.