Question

In: Computer Science

You has been requested to design and develop a food ordering system in C++ language based...

You has been requested to design and develop a food ordering system in C++ language based on following requirements:

The system shall allow the user to place an order for the food(s), view the food details, modify or delete the details of the food if necessary. Your program should be menu driven, giving the user various choices. You shall design the system by demonstrating the full understanding of object-oriented and use of list/link-list concept.

For every food order, the following information will be stored: Order ID (Auto assigned, unique ID), Food Code, flavor (example: Strawberry, chocolate), weight (Kg), Unit Price, Qty and customer information who order this cake. The customer information consists of customer ID, name, address and contact number. The order ID shall be automatically assigned with a unique ID when new order is added. The system shall display additional information that is amount (unit price * qty) when viewing the order details.

Solutions

Expert Solution

#include<iostream>
#include<fstream>
#include<string.h>
#include<conio.h>
#include<cstdio>
#include<stdlib.h>
using namespace std;
struct r{
    char dish[50];
    int key;
    float price;
}r;
class Resturant
{
public:
    void create();
    void query();
    void display();
    void update();
    void delet();
    void admin();
};
void Resturant::create()
{
    char a;
    int k;
    fstream obj;
    top:
    do {
        obj.open("resturant.txt",ios::in|ios::binary);
        cout<<"enter the dish key:";
        cin>>k;
         while(obj.read((char*)&r,sizeof(r)))
            {
                if(r.key==k)
                {
                    cout<<"key is already exist"<<endl;
                    obj.close();
                goto top;
                }
            }
        obj.close();
        obj.open("resturant.txt",ios::app|ios::binary);
        r.key=k;
        cin.ignore();
        cout<<"ENTER THE DISH NAME:";
        gets(r.dish);
        cout<<"ENTER THE DISH PRICE:";
        cin>>r.price;
        obj.write((char*)&r,sizeof(r));
        cout<<"do you want to add an other [y/n]:";
        cin>>a;
        obj.close();
    }
    while(a!='n');
}
void Resturant::display()
{
      int c=0;
     fstream obj;
     obj.open("resturant.txt",ios::in|ios::binary);
    cout<<"\tKey\t\tDISH NAME\t\tPRICE"<<endl;
    while(obj.read((char*)&r,sizeof(r)))
    {
            cout<<"\t"<<r.key<<"\t\t"<<r.dish<<"\t\t\t"<<r.price<<endl;
            c++;
    }
    if(c==0)
    {
        cout<<"list is empty"<<endl;
    }
    obj.close();
}
void Resturant::query()
{
     int a,c=0;
     fstream obj;
     obj.open("resturant.txt",ios::in);
    cout<<"enter the dish key:";
    cin>>a;
    while(obj.read((char*)&r,sizeof(r)))
    {
           if(r.key==a)
           {
            cout<<"\t"<<r.key<<"\t\t"<<r.dish<<"\t\t\t"<<r.price<<endl;
            c++;
           }
    }
    if(c==0)
    {
        cout<<"not found"<<endl;
    }
    obj.close();
}
void Resturant::update()
{
     int a,p,c=0;
     fstream obj;
     obj.open("resturant.txt",ios::in|ios::out|ios::binary);
    cout<<"enter the dish key:";
    cin>>a;
    obj.seekg(0);
    while(obj.read((char*)&r,sizeof(r)))
    {
        if(r.key==a)
        {
            cout<<"destinatio record:"<<endl;
            cout<<"\t"<<r.key<<"\t\t"<<r.dish<<"\t\t\t"<<r.price<<endl;
            p=obj.tellg()-(sizeof(r));
            obj.seekp(p);
            cout<<"enter the dish key:";
            cin>>r.key;
            cin.ignore();
            cout<<"ENTER THE DISH NAME:";
             gets(r.dish);
            cout<<"ENTER THE DISH PRICE:";
            cin>>r.price;
            obj.write((char*)&r,sizeof(r));
            c++;
           }

        }
        if(c==0)
        {
            cout<<"not found"<<endl;
        }

    obj.close();
}
void Resturant::delet()
{
     int a,c;
     fstream obj,obj1;
     obj.open("resturant.txt",ios::in|ios::binary);
     obj1.open("temp.txt",ios::app|ios::binary);
    cout<<"enter the dish key:";
    cin>>a;
    while(obj.read((char*)&r,sizeof(r)))
    {
        if(r.key==a)
        {
            c++;
            cout<<"\t"<<r.key<<"\t\t"<<r.dish<<"\t\t\t"<<r.price<<endl;
            cout<<"destination record is deleted"<<endl;
        }
        if(r.key!=a)
        {
            obj1.write((char*)&r,sizeof(r));
           }
    }
    obj.close();
    obj1.close();
    if(c==0)
       {
         cout<<"not found"<<endl;
       }
    remove("resturant.txt");
    rename("temp.txt","resturant.txt");
}
 void Resturant::admin()
{
char a;
    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) 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 MANU |"<<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 custmer:public Resturant
{
public:
    void bill();
    void showbill();
    void dish_menu();
};
void custmer::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("resturant.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 custmer::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 custmer::dish_menu()
 {
      fstream obj;
     obj.open("resturant.txt",ios::in|ios::binary);
    while(obj.read((char*)&r,sizeof(r)))
    {


            cout<<"\t\t"<<r.key<<") "<<r.dish<<"-------RS  "<<r.price<<endl;
    }
    obj.close();
 }
int main()
{
    char a;
    custmer 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)custmer     |"<<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 manu";
        cin>>a;
        switch(a)
        {
        case '0':
            break;
        case '1':
             system("CLS");
            obj.admin();
            break;
        case '2':
             system("CLS");
            obj.bill();
            break;
        }
    }
    while(a!='0');

}

Related Solutions

You has been requested to design and develop a food ordering system based on following requirements:...
You has been requested to design and develop a food ordering system based on following requirements: The system shall allow the user to place an order for the food(s), view the food details, modify or delete the details of the food if necessary. Your program should be menu driven, giving the user various choices. You shall design the system by demonstrating the full understanding of object-oriented and use of list/link-list concept. For every food order, the following information will be...
You has been requested to design and develop a food ordering system based on following requirements:...
You has been requested to design and develop a food ordering system based on following requirements: The system shall allow the user to place an order for the food(s), view the food details, modify or delete the details of the food if necessary. Your program should be menu driven, giving the user various choices. You shall design the system by demonstrating the full understanding of object-oriented and use of list/link-list concept. For every food order, the following information will be...
Using C language The system that you will develop holds the personal information for a number...
Using C language The system that you will develop holds the personal information for a number of students and the information of the course each student is registered in. The assumption is that each student is registered in a single course only. But the system will have a number of students saved. REQUIREMENTS: In this lab, you will introduce a simple student records system, which will save the student information as well as a single course that the student is...
C Language - The function 'make_enzyme_threads' has a memory bug. Fix this by simply re-ordering the...
C Language - The function 'make_enzyme_threads' has a memory bug. Fix this by simply re-ordering the lines in this function. It is simple fix but may take a while for you to find it. As a hint, you may want to pay attention to the addresses of the pointers that are passed to the individual enzymes. //enzyme.h contents //Note I could not use tag openers in the includes. #define _GNU_SOURCE #include (pthread.h) #include (stdio.h) #include (sys/types.h) #include (string.h) #include (stdlib.h)...
Use linked list and write in C++ Food ordering system 1. Place Order 2. View the...
Use linked list and write in C++ Food ordering system 1. Place Order 2. View the food details 3. Modify food details 4. Delete food details Order should let the customer to enter the food code, flavor, weight(kg), unit price, qty, customerID, name, address and contact number. It will also have an order id automatically assigned with a unique ID when new order is added. When view the food details, it should also calculate the unit price * qty as...
Use linked list and write in C++ Food ordering system 1. Place Order 2. View the...
Use linked list and write in C++ Food ordering system 1. Place Order 2. View the food details 3. Modify food details 4. Delete food details Order should let the customer to enter the food code, flavor, weight(kg), unit price, qty, customerID, name, address and contact number. It will also have an order id automatically assigned with a unique ID when new order is added. When view the food details, it should also calculate the unit price * qty as...
As a supervisor, you have been requested to assist junior employees to develop a career development...
As a supervisor, you have been requested to assist junior employees to develop a career development action plan (CDAP). Highlight the key critical stages useful in preparing the plan.
language is C++ 1. Design a class that manages a Pet Food Company's quarterly summarized activity....
language is C++ 1. Design a class that manages a Pet Food Company's quarterly summarized activity. It should contain the following: ( This is all private data ) Company Name - char[40] // This is a static member Quarter - char // This is a static member. Validate to be 1-4 in the setter method Division Name - char[40] BonusBudgetRate - float - set to 0.02 Total Sales - float Total Expenses - float 1a. Create a public method named...
Use list/link list and write in C++ Food ordering system 1. Place Order 2. View the...
Use list/link list and write in C++ Food ordering system 1. Place Order 2. View the food details 3. Modify food details 4. Delete food details 5. Exit Order should let the customer to enter the food code, flavor, weight(kg), unit price, qty, customer ID, name, address and contact number. It will also have an order id automatically assigned with a unique ID when new order is added. When view the food details, it should also calculate the unit price...
You have been requested to design a schema (as an E/R diagram) for the contact-tracing database....
You have been requested to design a schema (as an E/R diagram) for the contact-tracing database. Your group is busy working to design and field a contact-tracing database to be able to trace rapidly people who may have been in close proximity (contact) to someone diagnosed with a highly infectious disease. The Contact Tracing Domain To be able to trace with whom a person has been in contact, we need to know where that person has been and when. We...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT