Advertisement
adibahbab4108

C211009-ADIB

Sep 2nd, 2021
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.18 KB | None | 0 0
  1. #include<iostream>
  2. #include<conio.h>
  3. #include<fstream>
  4. using namespace std;
  5. class Restaurant
  6. {
  7.     int number,price,amount;
  8.     string name;
  9. public:
  10.     void Set_Value(int n,string nm,int p,int a)
  11.     {
  12.         number = n;
  13.         name = nm;
  14.         price = p;
  15.         amount = a;
  16.     }
  17.     void show_menu(int i)
  18.     {
  19.         cout<<"#"<<i<<endl;
  20.         cout<<"Name : "<<name<<endl;
  21.         cout<<"Price : "<<price<<endl;
  22.         cout<<"Amount : "<<amount<<endl;
  23.     }
  24.     void show_Bill(int Q)
  25.     {
  26.         cout<<"Name : "<<name<<endl;
  27.         cout<<"quantity: "<<Q<<endl;
  28.         cout<<"Total Bill : "<<price*Q<<endl<<endl;
  29.         cout<<"Thank you!";
  30.     }
  31.  
  32. };
  33. int main()
  34. {
  35.     Restaurant Manager[20];
  36.     int items,choose,i,v2;
  37.     ofstream savedMenu;
  38.     savedMenu.open("Restaurant Management.txt");
  39.  
  40.     cout<<"1. Add new items"<<"\n"<<"2. Skip"<<endl;
  41.     cin>>v2;
  42.     if(v2==1)
  43.     {
  44.         cout<<"How many items: ";
  45.         cin>>items;
  46.  
  47.         for(int i=1; i<=items; i++)
  48.         {
  49.             int number,price,amount;
  50.             string name;
  51.  
  52.             cout<<"#"<<i<<endl;
  53.             savedMenu<<"#"<<i<<endl;
  54.             cout<<"Name : ";
  55.             cin>>name;
  56.             savedMenu<<"Name : "<<name<<endl;
  57.             cout<<"Price : ";
  58.             cin>>price;
  59.             savedMenu<<"Price : "<<price<<endl;
  60.             cout<<"Amount : ";
  61.             cin>>amount;
  62.             savedMenu<<"Amount : "<<amount<<endl;
  63.             cin.ignore();
  64.             Manager[i].Set_Value(number,name,price,amount);
  65.         }
  66.         savedMenu.close();
  67.     }
  68.  
  69.  
  70.     cout<<"===================================="<<endl;
  71.     cout<<"   Welcome to Restaurant"<<endl<<endl;
  72.     cout<<"1. See all"<<endl<<"2. Select "<<endl<<endl;
  73.     cout<<"select :";
  74.     cin>>choose;
  75.     if(choose==1)
  76.     {
  77.         for(int i=1; i<=items; i++)
  78.         {
  79.             Manager[i].show_menu(i);
  80.             cout<<endl;
  81.         }
  82.     }
  83.     cout<<"Select items : ";
  84.     cin>>i;
  85.  
  86.     int quntty;
  87.     cout<<"select quantity : "<<endl;
  88.     cin>>quntty;
  89.     cout<<"\n"<<"You have selected : #"<<i<<endl;
  90.     Manager[i].show_Bill(quntty);
  91.     getch();
  92.     return 0;
  93. }
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement