题目:开心区餐厅是广州市的一家餐厅。餐厅主要供应一般的食物和饮料,如酒、餐、蔬菜、海鲜等(如表1所示)。为了成为一家高级国际餐厅,餐厅要求每桌的最后帐单必须是100%正确的。因此,餐厅决定开发一个由收银员选择食物或饮料,然后计算和输出最终客户的帐单的系统。经理现在要求您完成这项工作,他希望系统能由收银员选择食物或饮料,然后程序将计算并输出最终帐单。
问题:paymoney的价格怎么算?不会。
情况:目前大体上程序可以运行,就是价格运算有问题。
#include<iostream>
#include<stdio.h>
struct food
{
int ID;
char Name[50];
char typr[20];
float price;
int number; //点菜时考虑点几分
};
void payMoney()
{
int n,m,total;
total=n+m;
printf("food %dRMB\n",n);
printf("Drink %dRMB\n",m);
printf("Total:%dRMB\n",total);
}
void ShowMainMenu()
{
printf("\n*********************************\n");
printf("* 1.点菜 *\n");
printf("* 2.结账 *\n");
printf("* 3.增加新菜品 *\n");
printf("* 4.退出 *\n");
printf("\n*********************************\n");
}
int ShowMenu()
{
food fd[8]=
{{1,"Curry beef with rice","food",40,0},
{2,"Sushi set meal","food",65,0},
{3,"YangZhou fire rice","food",45,0},
{4,"Sirloin Steak with Spaghetti","food",72,0},
{5,"Chicken vegetable roll","food",42,0},
{6,"Soft drink\t" ,"drink",10,0},
{7,"Red wine\t" ,"drink",10,0},
{8,"Beer\t" ,"drink",10,0},} ;
printf("\n#########################################\n");
for(int i=0;i<8;i++)
{
printf("#%d.%s\t %10.2f$\t #\n",fd[i].ID,fd[i].Name,fd[i].price);
}
int sel=0;
while(1)
{
scanf("%d",&sel);
switch(sel)
{
case 0:
ShowMainMenu();
return 1;
default:
printf("已点好了%d号菜了,如果点完菜,请按'0'退出\n",sel);
break;
}
}
}
void SelectMainMenu()
{
char c;
while(1)
{
scanf("%c",&c);
switch(c)
{
case '1':
ShowMenu();
break;
case '2':
payMoney();
break;
case '4':
return;
}
}
}
#include<stdio.h>
#include"jiegou.h"
int main()
{
printf("*****************开心区餐厅*******************\n");
printf("*****************欢迎您点菜*******************\n");
ShowMainMenu();
SelectMainMenu();
payMoney();
return 0;
}