为了账号安全,请及时绑定邮箱和手机立即绑定

求改代码,多了四种折扣支付功能,微信(75%),微信会员(85%),银行卡(15%),以及现金,求大神指教

求改代码,多了四种折扣支付功能,微信(75%),微信会员(85%),银行卡(15%),以及现金,求大神指教

C++
someOne_forward 2016-06-11 13:05:50
#include<stdlib.h>#include<time.h>#include <iostream>using namespace std; //基本的展示函数/*void printtime(){ struct tm *ptr;  time_t lt;  char str[80];  lt=time(NULL);  ptr=localtime(&lt);  strftime(str,200,"%F %R",ptr);  cout<<str; }*/void showMenuName(int x){ switch (x) { case 1:cout<<"工作日特惠午餐";break; case 2:cout<<"美式大薯格";break; case 3:cout<<"可乐";break; case 4:cout<<"草莓冰淇淋"; }} void showcashier(int x) { switch(x) { case 1:cout<<"小李";break; case 2:cout<<"小麦";break; default:cout<<"小雨"; } } void showserver(int x) { switch (x) { case 1:cout<< "小张";break; case 2:cout<<"小华";break; default :cout<<"小马";break; } } //菜单的各种定义class Menu{ double price[4]; double count[4];public: void inputcount(int x); void zero(); void printMenu();};void Menu::zero(){ price[0]=30; price[1]=19; price[2]=8; price[3]=5; for(int i=0;i<4;i++) { count[i]=0; }}void Menu::inputcount(int x){ x=x-1; cout<<"需要多少份"<<endl; cin>>count[x];}void Menu::printMenu(){ int total=0; cout<<"名称\t\t"<<"单价\t"<<"数量\t"<<endl; for(int i=0;i<4;i++) { if(count[i]!=0) { showMenuName(i+1); cout<<"\t"<<price[i]<<"\t"; cout<<count[i]<<endl; total=total+price[i]*count[i]; } } cout<<"合计\t\t\t"<<total;}//账单的各种定义class Cbill{ int cashier; int server; int Table; int number;public: void intput(); void printbill();};void Cbill::printbill(){ //printtime(); cout<<"========================================="<<endl; cout<<"收银人:"; showcashier(cashier); cout<<endl; cout<<"服务员:"; showserver(server); cout<<endl; cout<<"桌号:"<<Table<<endl; cout<<"顾客人数:"<<number<<endl; cout<<"========================================="<<endl;}void Cbill::intput(){ for(int i=1;i<=3;i++) { showcashier(i); cout<<"\t"<<i<<endl; } cout<<"输入收银员编号"<<endl; cin>>cashier; for(int i=1;i<=3;i++) { showserver(i); cout<<"\t"<<i<<endl; } cout<<"输入服务员编号"<<endl; cin>>server; cout<<"输入桌号"<<endl; cin>>Table; cout<<"输入顾客数"<<endl; cin>>number;}void main(){ Menu M1; M1.zero();//为菜单初始化 Cbill C1; C1.intput();//为账单初始化 //展示菜单 int x; for(int i=1;i<=4;i++) { showMenuName(i); cout<<"\t"<<i<<endl; } //输入菜单 while(1) { cout<<"请输入菜单编号(输入0表示退出并打印账单)"<<endl; cin>>x; if (x==0)break; else if(x<=4&&x>0) M1.inputcount(x); else cout<<"错误输入"<<endl; } C1.printbill(); M1.printMenu(); system("pause");}
查看完整描述

目前暂无任何回答

  • 0 回答
  • 1 关注
  • 1433 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信