//#include <stdafx.h>
#include <iostream>
using namespace std;
class Menu
{
private:
int mune_number;
int object;
int sum_price;
int customer;
public:
void foodname();
void price();
};
void Menu::foodname()
{
cout<<"Happy Everday!"<<endl;
cout<<" "<<endl;
cout<<"Calclation Systeem: "<<endl;
cout<<"In this system, you can calculate the bill depend on your input! Thanks!"<<endl;
cout<<"Please input the number of the customer"<<endl;
int sum_price=0;//由于在类的私有权限中,已经定义了这两个变量,所以在该程序运行的过程中,程序会执行就近原则,而去重新调用没有赋值的变量,导致最终该变量
cout<<"OK!"<<customer<<" "<<"person in the bill."<<endl;
sum_price +=3*customer;
cout<<"The menu shows: "<<endl;
cout<<"Food: "<<endl;
cout<<"Code Name Price "<<endl;
cout<<"1 Curry beef with rice ¥40.00"<<endl;
cout<<"2 Sushi set meal ¥65.00"<<endl;
cout<<"3 YangZhou fried rice ¥45.00"<<endl;
cout<<"4 Sirloin Steak with Spaghetti ¥72.00"<<endl;
cout<<"5 Chicken vegetable roll ¥42.00 "<<endl;
cout<<"Drink: "<<endl;
cout<<"21 Soft drink ¥10.00 "<<endl;
cout<<"22 Red wine ¥15.00"<<endl;
cout<<"23 Beer ¥15.00"<<endl;
}
void Menu::price()
{
int object=1;
while (object==1)
{
cout<<"Please input the code of the order:( one time one code)" <<endl;
cout<<"Digital only input is 1,2,3,4,5,21,22,23."<<endl;
cin>>mune_number;
switch ( mune_number )
{
case 1:
sum_price +=40;
break;
case 2:
sum_price +=65;
break;
case 3:
sum_price +=45;
break;
case 4:
sum_price +=74;
break;
case 5:
sum_price +=42;
break;
case 21:
sum_price +=10;
break;
case 22:
sum_price +=15;
break;
case 23:
sum_price +=15;
break;
}
cout<<"Any more ?(1-Yes,2-No)"<<endl;
cin>>object;
if (object==2)
break;
}
cout <<"The total price is "<<sum_price<<endl;
}
int main ()
{
Menu object;
object.foodname();
object.price();
system("pause");
}
#include <iostream>
using namespace std;
class Menu
{
private:
int mune_number;
int object;
int sum_price;
int customer;
public:
void foodname();
void price();
};
void Menu::foodname()
{
cout<<"Happy Everday!"<<endl;
cout<<" "<<endl;
cout<<"Calclation Systeem: "<<endl;
cout<<"In this system, you can calculate the bill depend on your input! Thanks!"<<endl;
cout<<"Please input the number of the customer"<<endl;
int sum_price=0;//由于在类的私有权限中,已经定义了这两个变量,所以在该程序运行的过程中,程序会执行就近原则,而去重新调用没有赋值的变量,导致最终该变量
int customer=0;//的值悬空出现垃圾值
cin>>customer;cout<<"OK!"<<customer<<" "<<"person in the bill."<<endl;
sum_price +=3*customer;
cout<<"The menu shows: "<<endl;
cout<<"Food: "<<endl;
cout<<"Code Name Price "<<endl;
cout<<"1 Curry beef with rice ¥40.00"<<endl;
cout<<"2 Sushi set meal ¥65.00"<<endl;
cout<<"3 YangZhou fried rice ¥45.00"<<endl;
cout<<"4 Sirloin Steak with Spaghetti ¥72.00"<<endl;
cout<<"5 Chicken vegetable roll ¥42.00 "<<endl;
cout<<"Drink: "<<endl;
cout<<"21 Soft drink ¥10.00 "<<endl;
cout<<"22 Red wine ¥15.00"<<endl;
cout<<"23 Beer ¥15.00"<<endl;
}
void Menu::price()
{
int object=1;
while (object==1)
{
cout<<"Please input the code of the order:( one time one code)" <<endl;
cout<<"Digital only input is 1,2,3,4,5,21,22,23."<<endl;
cin>>mune_number;
switch ( mune_number )
{
case 1:
sum_price +=40;
break;
case 2:
sum_price +=65;
break;
case 3:
sum_price +=45;
break;
case 4:
sum_price +=74;
break;
case 5:
sum_price +=42;
break;
case 21:
sum_price +=10;
break;
case 22:
sum_price +=15;
break;
case 23:
sum_price +=15;
break;
}
cout<<"Any more ?(1-Yes,2-No)"<<endl;
cin>>object;
if (object==2)
break;
}
cout <<"The total price is "<<sum_price<<endl;
}
int main ()
{
Menu object;
object.foodname();
object.price();
system("pause");
}