C语言自制简单点菜系统

  • Post author:
  • Post category:其他


该系统完成以下功能:

1.点餐,进入点餐界面,选择菜品。

2.添菜,在已点菜品的基础上增加菜品。

3.减菜,在已点菜品基础上减少菜品。

4.结算,根据已点菜品计算价格。

0.退出。

#include <stdio.h>
 void main_munu()
 {
  char a[6][20]={"","点餐","添菜","减菜","结算"};
  int i;
  
  for(i=1;i<5;i++)
  {
    printf("\t%d.%s\n",i,a[i]);
  }
  printf("\t0.点餐结束\n");
}
void menu_caipin(){
char a[10][20]={"宫保鸡丁  10","酱爆鸭片  18","木须肉   15","沸腾鱼   88",
"手撕圆白菜 12","麻婆豆腐   8","小鸡炖蘑菇 48","水晶肘子  58","米饭    3","香酥带鱼  25"};//定义字符数组,存放菜名
  printf("请具体选择菜品:\n");
  for (int i = 0; i < 10; i ++) {
    printf("\t\t%d.%s\n",i+1,a[i]);
  }
  printf("\t\t0.返回上层菜单\n");
}
int main(int agrc,const char *argv[])
 {
  printf("*******河北农大中餐店 *****\n");
  printf("****** 欢迎您点餐 *********\n");
  int M;
  int n;
  int k;
  int m;
  int x[10] = {0};
  int price1[10] = {0};
  int price[10] = {10,18,15,88,12,8,48,58,3,25};
  int total = 0;
  char name[10][20]={"宫保鸡丁 ","酱爆鸭片 ","木须肉  ","沸腾鱼  ","手撕圆白菜","麻婆豆腐 ","小鸡炖蘑菇","水晶肘子 ","米饭        ","香酥带鱼 "};

while (1) {
do {
	main_munu();
    scanf("%d",&M);
	if(M==0)
		break;
    switch (M)
	{
      case 1:
      {
    	menu_caipin();
        while (1) 
		{
          scanf("%d",&n);
		 if (n == 0)
		{
		  break;} 
          price1[n-1] += price[n-1];
          x [n-1] ++;
		  }
          
        }if (n == 0)break;
	
	 case 2:
      {	menu_caipin();
        printf("请选择要添加的菜:>");
	     
 while(1)
	{scanf("%d",&k);
	if (k == 0) {
            
            break;
          }
        
          price1[k-1] += price[k-1];
          x [k-1] ++; 
        }
	} 
	      if(k == 0)break;
      case 3:
      {
	
       printf("请选择要减少的菜:>");
       menu_caipin();
	while(1)
	{
	scanf("%d",&m);
		if(m==0)
	     {
		 break;}
		 price1[m-1] -= price[m-1];
          x [m-1] --; 
	}
	
      }

        if(m == 0)break;
   case 4:
      {
      printf("菜名\t\t单价(元)\t数量\t总价格(元)\n-----------------------------------\n");
	    for (int j = 0; j < 10; j++) 
     {
      if (price1[j] != 0) {
        printf("%s\t\t%3d\t\t%3d\t%3d\n",name[j],price[j],x[j],price1[j]);
         total += price1[j];
      }
	  }
	  printf("总价格:\t\t\t\t\t%3d\n",total);
	  printf("祝您用餐愉快,期待您的下次光临!\n");
	  break;
	  }
	  break;}
	   
        if(n == 0)
		break;
    }

	while(n) ;}
    return 0;
}



版权声明:本文为alptou原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。