Advertisement
adibahbab4108

C211009-ADIB

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