Answer to Question #4232 in C++ for Vineeth Abraham Shaji
2011-09-08T04:40:37-04:00
Write aprogram in c++ to print hotel bill.The input will be given by the hotel staffs.They will be given option to choose the menu and price will be shown automaticall.The hotel bill will show the item's name,Its quantity and its price along with hotels name and also that days date.
Plz use only the following function as we learned till there..the functions are if else,all loops and also switch statement.the exit function can also be used and all other basic functions can be used...
thx in advance
1
2011-10-14T11:14:20-0400
// Hotel bill.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "iostream" #include "conio.h" #include<time.h> using namespace std; int count=-1; struct Dish{ char* name; int quantity; double price; }; Dish dishes[1000]; void Close(){ exit(0); } int includemenu[1000]; int menuitem=0; void Menu(){ do{ & cout<<"\nMenu\n\n"; & cout <<"Select the item:\n"; & cout<<"1 - Pesto pizza& & 8.5$\n"; & cout<<"2 - CLASSIC BRUSCHETTA 9.5$\n"; & cout<<"3 - PEPPER KANGARO& 19.5$\n"; & cout<<"4 - THE ROCKS CAESAR& & 15$\n"; & cout<<"5 - SALT WATER CROCODILE& 19.5$\n"; & cout<<"6 - CRISPY BACON& & 16.5$\n"; & cout<<"7 - TANDOORI CHICKEN& 17.5$\n"; & cout<<"8 - Smoked Salami 16.5$\n"; & cout<<"9 - POTATO WEDGES& 8.5$\n"; & cout<<"10 - Exit from menu\n"; & cin>>menuitem; & count++; switch(menuitem){ & case 1: & dishes[1].name ="Pesto pizza"; & dishes[1].price =8.5; & dishes[1].quantity ++; & includemenu[count]=1; & & break; & case 2: & dishes[2].name ="CLASSIC BRUSCHETTA"; & dishes[2].price =9.5; & dishes[2].quantity ++; & includemenu[count]=2; & break; & case 3: & dishes[3].name ="PEPPER KANGARO"; & dishes[3].price =19.5; & dishes[3].quantity ++; & includemenu[count]=3; & break; & case 4: & dishes[4].name ="THE ROCKS CAESAR"; & dishes[4].price =15; & dishes[4].quantity ++; & includemenu[count]=4; & break; & case 5: & dishes[5].name ="SALT WATER CROCODILE"; & dishes[5].price =19.5; & dishes[5].quantity ++; & includemenu[count]=5; & break; & case 6: & dishes[6].name ="CRISPY BACON"; & dishes[6].price =19.5; & dishes[6].quantity ++; & includemenu[count]=6; & break; & case 7: & dishes[7].name ="TANDOORI CHICKEN"; & dishes[7].price =19.5; & dishes[7].quantity ++; & includemenu[count]=7; & break; & case 8: & dishes[8].name ="Smoked Salami"; & dishes[8].price =19.5; & dishes[8].quantity ++; & includemenu[count]=8; & break; & case 9: & dishes[9].name ="POTATO WEDGES"; & dishes[9].price =19.5; & dishes[9].quantity ++; & includemenu[count]=9; & break; } } while(menuitem!=10); } void showhotelbill(){ char date[9]; _strdate(date); cout<<"Item's name Quantity & Price Hotel Name & Date\n"; for(int i=0;i<count;i++ ){ cout<<dishes[includemenu[i]].name<<" quot;<<dishes[includemenu[i]].quantity<<" quot;<<dishes[includemenu[i]].price<<"$ Hotel name & quot;<<" & quot;<<date<<"\n"; } } int _tmain(int argc, _TCHAR* argv[]) { int k=0; do{ & cout <<"Select a option:\n"; & cout<<"1- Choose the menu\n"; & cout<<"2- Print hotel bill\n"; & cout<<"3- Exit\n"; & cin>>k; & switch(k){ & case 1: & Menu(); & & break; & case 2: & showhotelbill(); & break; & case 3: & Close(); & break; & } } while(k!=3); getch(); return 0; }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS !
Learn more about our help with Assignments:
C++
Comments
Leave a comment