Answer to Question #203546 in C++ for DemoZai

Question #203546

Cake Ordering System

1)     Add a new order

Let user add a new cake order into the system.

System will store the following cake information into a binary heap.


Cake information contain:

a)      Order ID (auto-generated)

b)     Expected delivery data and time

c)      Name of the cake (e.g., butter cake, biscuit cake and etc.

d)     Weight (in kg)

e)     Price

f)       Status (set to “new” when a new order is created)


2)     Retrieve an order

System shall retrieve and remove the order (with the nearest delivery data and time) from the binary heap data structure and update the status as “in progress” and move the order into a queue data structure.







1
Expert's answer
2021-06-06T08:54:18-0400


#include <iostream>


using namespace std;
struct orders{
    int id;string date_time;string name;
    double weight,price;
    string status;
};
void addOrder(){
    // int n;
    // cout<<"\nEnter number of orders to add: ";
    // cin>>n;
    struct orders d;
    cout<<"\nEnter order id: ";
    cin>>d.id;
    cout<<"\nEnter Expected delivery data and time: ";
    cin>>d.date_time;
    cout<<"\nEnter name: ";
    cin>>d.name;
    cout<<"\nEnter weight: ";
    cin>>d.weight;
    cout<<"\nEnter price: ";
    cin>>d.price;
    cout<<"\nEnter status: ";
    cin>>d.status;
}
void retrieveOrder(){
    struct orders d;
    cout<<"\nOrder Id: "<<d.id<<endl;
    cout<<"\nDate and time: "<<d.date_time<<endl;
    cout<<"\nOrder name: "<<d.name<<endl;
    cout<<"\nOrder Weight: "<<d.weight<<endl;
    cout<<"\nOrder Price: "<<d.price<<endl;
    cout<<"\nOrder status: "<<d.status<<endl;
}
int main()
{
    cout<<"Main Menu\n";
    cout<<"1. Add a new Order\n2. Retrieve an order";
    int ch;
    cout<<"\nEnter your choice: ";
    cin>>ch;
    if (ch==1){
        addOrder();
    }
    else if(ch==2){
        retrieveOrder();
    }
    


    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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog