struct { char d[50]; float p,amount; int qty; }rd; class Order:public Restaurant { public:     void bill();     void showbill();     void dish_menu(); }; void Order::bill() {      int a,c=0;      char ch;      float total=0;     fstream obj,obj1;     dish_menu();     obj1.open("bill.txt",ios::out|ios::binary);      do{     obj.open("restaurant.txt",ios::in|ios::binary);     cout<<"enter the dish key:";     cin>>a;     while(obj.read((char*)&r,sizeof(r)))     {            if(r.key==a)            {             c++;             cout<<"enter the quantity:";             cin>>rd.qty;             rd.amount=rd.qty*r.price;             cout<<"\t"<>ch;     obj.close();      }      while(ch!='n');     obj1.close();     cout<<"||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"<>a;         switch(a)         {         case '0':             break;         case '1':              system("CLS");             obj.admin();             break;         case '2':              system("CLS");             obj.bill();             break;         }     }     while(a!='0'); }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Another half of my code:

 

           cout<<"\n\t\t\t\t\t\t|||||||||||||||||||||||||"<<endl;
            cout<<"\t\t\t\t\t\t|                       |"<<endl;
            cout<<"\t\t\t\t\t\t|  1) ADD DISH          |"<<endl;
            cout<<"\t\t\t\t\t\t|  2) Display           |"<<endl;
            cout<<"\t\t\t\t\t\t|  3) QUERY             |"<<endl;
            cout<<"\t\t\t\t\t\t|  4) UPDATE            |"<<endl;
            cout<<"\t\t\t\t\t\t|  5) DELETE            |"<<endl;
            cout<<"\t\t\t\t\t\t|  0) EXIT TO MAIN MENU |"<<endl;
            cout<<"\t\t\t\t\t\t|                       |"<<endl;
            cout<<"\t\t\t\t\t\t|||||||||||||||||||||||||"<<endl;
            cout<<"\t\t\t\t\t\tselect the key";
            cin>>a;
            switch(a)
            {
            case '0':
                break;
            case '1':
                system("CLS");
               create();
                break;
            case '2':
                system("CLS");
               display();
                break;
            case '3':
                system("CLS");
               query();
                break;
            case '4':
                system("CLS");
               update();
                break;
            case '5':
                system("CLS");
             delet();
                break;
            }
    }
    while(a!='0');
}
struct {
char d[50];
float p,amount;
int qty;
}rd;
class Order:public Restaurant
{
public:
    void bill();
    void showbill();
    void dish_menu();
};
void Order::bill()
{
     int a,c=0;
     char ch;
     float total=0;
    fstream obj,obj1;
    dish_menu();
    obj1.open("bill.txt",ios::out|ios::binary);
     do{
    obj.open("restaurant.txt",ios::in|ios::binary);
    cout<<"enter the dish key:";
    cin>>a;
    while(obj.read((char*)&r,sizeof(r)))
    {
           if(r.key==a)
           {
            c++;
            cout<<"enter the quantity:";
            cin>>rd.qty;
            rd.amount=rd.qty*r.price;
            cout<<"\t"<<r.dish<<"\t\t"<<r.price<<"*"<<rd.qty<<"\t\t"<<rd.amount<<endl;
            strcpy(rd.d,r.dish);
            rd.p=r.price;
            obj1.write((char*)&rd,sizeof(rd));
            total=total+rd.amount;
           }
        }
        if(c==0)
     {
        cout<<"not found"<<endl;
     }

    cout<<"do you want to order more [y/n]";
    cin>>ch;
    obj.close();
     }
     while(ch!='n');
    obj1.close();
    cout<<"||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"<<endl;
    cout<<"|||||||||||||||||||||||||||||||||||||||||||||||| BILL  |||||||||||||||||||||||||||||||||||||||||||||||||||||||"<<endl;
     cout<<"||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"<<endl;
    showbill();
    cout<<"||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"<<endl;
    cout<<"|||\t\t\t\t\t\t\t   TOTAL="<<total<<"\t\t\t\t\t   |||"<<endl;
    cout<<"||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"<<endl;
}
 void Order::showbill(){
    fstream obj;
    obj.open("bill.txt",ios::in|ios::binary);
    cout<<"\tDISH NAME\t\tPRICE\t\tQTY\t\tAMOUNT"<<endl;
    while(obj.read((char*)&rd,sizeof(rd)))
    {

            cout<<"\t"<<rd.d<<"\t\t\t"<<rd.p<<"\t\t"<<rd.qty<<"\t\t"<<rd.amount<<endl;


    }
    obj.close();
 }
 void Order::dish_menu()
 {
      fstream obj;
     obj.open("restaurant.txt",ios::in|ios::binary);
    while(obj.read((char*)&r,sizeof(r)))
    {


            cout<<"\t\t"<<r.key<<") "<<r.dish<<"-------RM  "<<r.price<<endl;
    }
    obj.close();
 }
int main()
{
    char a;
    Order obj;
    do
    {
        cout<<"\n\t\t\t\t\t\t||||||||||||||||||||"<<endl;
        cout<<"\t\t\t\t\t\t|                  |"<<endl;
        cout<<"\t\t\t\t\t\t|    1)Admin       |"<<endl;
        cout<<"\t\t\t\t\t\t|    2)Order     |"<<endl;
        cout<<"\t\t\t\t\t\t|    0)Exit        |"<<endl;
        cout<<"\t\t\t\t\t\t|                  |"<<endl;
        cout<<"\t\t\t\t\t\t||||||||||||||||||||"<<endl;
        cout<<"\t\t\t\t\t\tselect the menu";
        cin>>a;
        switch(a)
        {
        case '0':
            break;
        case '1':
             system("CLS");
            obj.admin();
            break;
        case '2':
             system("CLS");
            obj.bill();
            break;
        }
    }
    while(a!='0');

}

 

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education