Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON PROGRAMMING: Write a program to help a local restaurant automate its brea

ID: 3913356 • Letter: P

Question

PYTHON PROGRAMMING:

Write a program to help a local restaurant automate its breakfast billing system. The program should do the following:

a. Show the customer the different breakfast items offered by the restaurant.

b. Take customer order

c. Change customer order

d. Display all orders

e. Delete a customer order  

f. Allow the customer to select more than one item from the menu

g. Display the order information. The order should include a 6-digit order number. Each order number must be unique

a. Once a customer’s order has been displayed, the program should return to the main menu

h. Keep track of all orders

To build this application, students will use multiple classes and modules.

1. client module (client.py). This module will contain the main program that the user interacts with. It should contain two functions: mainMenu and orderMenu. mainMenu function will display the program main options. orderMenu function displays the order menu and price of each item.  

2. order module (order.py). This module will contain a class, Order, that represents an order. Each order can have customer name , order number, order items and their prices, tax amount, and total. There should be set and get methods for each attribute except the order number. The order number should only have a get method. The order number is generated when an order is created. The order number must be created within the Order class, it cannot be passed an in argument. The order number is a 6-digit number

3. orderDatabase module (orderDatabase.py). This module will be used to store, retrieve, and manipulate orders. It will contain a class, OrderDB, that will contain all the required functionality for working with orders.

a. OrderDB class methods

i. addOrder method. This method takes an order object as parameter and adds it to the order database

ii. changeOrderAddItem method. This method takes as parameters the order number and item (name and price) that will be added to an order. The order will be updated in the database. The updated order is returned

iii. changeOrderRemoveItem method. This method takes as parameters the order number and item (name and price) that will be remove from the order. The order will be updated in the database. The updated order is returned.  

iv. findOrder method. This method takes as parameter the order number of the order to find. Once the order is located, the method returns the order. If the order is not found, the method returns None

v. findCustomerOrders method. This method takes the customer name as parameter and returns all orders for that customer

vi. printAllOrders method. This method returns all orders in the database.  

vii. deleteOrder method. This method takes the order number as a parameter and removes the order associated with the order number from the database. It returns the deleted order

viii. deleteCustomerOrders method. This method take the customer name as a parameter, finds all orders for that customer, and deletes them. This method returns the deleted orders.  

ix. deleteAllOrders method. This method deletes all orders from the database and display the number of orders deleted.  

When the program begins, the following options will be presented to the user:

1. Make An Order

2. Change An Order

3. Find Single Order

4. Find Customer Orders

5. Display Orders

6. Delete Single Order

7. Delete Customer Orders

8. Delete all orders

9. exit

Option 1 (Make An Order)

When the user selects this option, the program should present the menu for breakfast items and prompt the user to make a selection. The user will enter the number that corresponds to a menu item. Once the user makes a selection, the program will add the item to order and prompt the user to make another selection (To keep things simple, an item can only appear in an order one time), if the user has finished ordering they will hit enter at the prompt without enter a value. The program will prompt for the customer name. Once the name is entered, the program will calculate the order tax and total, create an order, add the order to the database, and display the order information. The program will return to the main menu

1. Plain Egg $1.45

2. Bacon and Egg $2.45

3. Muffin $0.99

4. French Toast $1.99

5. Fruit Basket $2.49

6. Cereal $0.50

7. Coffee $0.50

8. Tea $0.75

Note: Sales tax is 5%

Example Order Information

Name: Jane

Order number: 456797

Bacon and Egg $2.45

Muffin $0.99

Coffee $.50

Tax $.20

Amount Due $4.14

Option 2 (Change An Order)

When this option is selected, the user will be prompted for the order number. Once the order number is entered, the program will present the user with another prompt asking if they will like to add or remove an item from the order. The user will enter 1 to add item or 2 to remove item. The program will prompt for the name of the item to add or remove. If the user’s response is 1, the changeOrderAddItem method from OrderDB will be called and passed the item name and price. If the user’s response was 2, the changeOrderRemoveItem method from OrderDB will called and passed the item name and price. The program will display the updated order.

Option 3 (Find Single Order)

When this option is selected, the program will prompt for the order number. Once the order number is entered, the program will call findOder method from the OrderDB class and pass in the order it. If the order exists, the program will display the order information.  

Option 4 (Find Customer Orders)

When this option is selected, the program will prompt for the customer name. The program will call findCustomerOrders from OrderDB class and pass in the customer name. The program will display all orders found for the customer.

Example Order Information

Name: Jane

Order number: 456797

Bacon and Egg $2.45

Muffin $0.99

Coffee $.50

Tax $.20

Amount Due $4.14

Option 5 (Display Orders)

When this option is selected, the program will call PrintOrders from OrderDB class.  

Option 6 (Delete Single Order)

When this option is selected, the program will prompt for the order number. The order number will be passed to the deleteOrder method from OrderDB class. The deleted order information must be displayed

Option 7(Delete Customer Orders)

When this option is selected, the program will prompt for the customer name. Once the customer name is provided, the program will call the deleteCustomerOrders method from OrderDB class. The deleted order information must be displayed

Option 8 (Delete All Orders)

When this option is selected, the program will call deleteAllOrders method from OrderDB class.

Explanation / Answer

The code is in C++

#include<iostream>

#include<string>

#include <iomanip>

using namespace std;

struct menuitem //defintion of a struct to store data about resturant

{

       string menulist;

       double price;

};

menuitem menu[8]; //Instance of a struct to store data of 7 resturant items

void getdata(); //prototype of a function to loads data about the items in struct

void showdata(); // prototype of a function show the loaded data

void selectItems(); //prototype of a function to select the items

void cal(); //prototype of a function to calculate the bill

int c[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };

int main()

{

       double t;

       getdata(); //Calling of a function to get load the data

       showdata();//calling of a function to display data

       selectItems(); //calling of a function select the items from the menu

       cal(); //calling of a function to calculate the bill

       //system("pause");

       return 0;

}

void getdata() //a function to get load the data

{

       menu[1].menulist = "Plain Egg";

       menu[1].price = 15.00;

       menu[2].menulist = "Omelet";

       menu[2].price = 15.00;

       menu[3].menulist = "Paratha";

       menu[3].price = 12.00;

       menu[4].menulist = "French Toast";

       menu[4].price = 20.99;

       menu[5].menulist = "Fruit Basket";

       menu[5].price = 120.49;

       menu[6].menulist = "Coffee";

       menu[6].price = 50.00;

       menu[7].menulist = "Tea";

       menu[7].price = 20.00;

}

void showdata() //a function to display menu

{

       cout << "Breakfast items offered by the restaurant are" << endl;

       cout << 1 << " " << menu[1].menulist << setw(12) << "RS " << menu[1].price << endl;

       cout << 2 << " " << menu[2].menulist << setw(15) << "RS " << menu[2].price << endl;

       cout << 3 << " " << menu[3].menulist << setw(14) << "RS " << menu[3].price << endl;

       cout << 4 << " " << menu[4].menulist << setw(9) << "RS " << menu[4].price << endl;

       cout << 5 << " " << menu[5].menulist << setw(9) << "RS " << menu[5].price << endl;

       cout << 6 << " " << menu[6].menulist << setw(15) << "RS " << menu[6].price << endl;

       cout << 7 << " " << menu[7].menulist << setw(18) << "RS " << menu[7].price << endl;

}

void selectItems() //function select the items from the menu

{

       int ch,quantity;

       char con;

       do{

              cout << "Enter your choice :";

              cin >> ch; //takes the choice from the user to select the item

              cout << "Enter the Quantity :";

              cin >> quantity;

              switch (ch)

              {

              case 1:

              {

                     c[1] = c[1] + quantity;

                     cout << "You have Selected :" << menu[1].menulist << endl;

                     break;

              }

              case 2:

              {

                     c[2] = c[2] + quantity;

                     cout << "You have Selected :" << menu[2].menulist << endl;

                     break;

              }

              case 3:

              {

                     c[3] = c[3] + quantity;

                     cout << "You have Selected :" << menu[3].menulist << endl;

                     break;

              }

              case 4:

              {

                     c[4] = c[4] + quantity;

                     cout << "You have Selected :" << menu[4].menulist << endl;

                     break;

              }

              case 5:

              {

                     c[5] = c[5] + quantity;

                     cout << "You have Selected :" << menu[5].menulist << endl;

                     break;

              }

              case 6:

              {

                     c[6] = c[6] + quantity;

                     cout << "You have Selected :" << menu[6].menulist << endl;

                     break;

              }

              case 7:

              {

                     c[7] = c[7] + quantity;

                     cout << "You have Selected :" << menu[7].menulist << endl;

                     break;

              }

              default:

                     cout << "invalid input" << endl;

              }

              cout << "to select more items (y/n)";

              cin >> con;

       } while (con != 'n');

       cout << endl;

}

void cal()

{

       double total = 0, tax, due;

       cout << "------Welcome to Café international-----" << endl;

       for (int i = 1; i < 8; i++)

       {

              if (c[i] > 0)

              {

                     cout << c[i] << " " << menu[i].menulist << "   RS " << menu[i].price << endl;

                     total = total + (menu[i].price*c[i]);

              }

       }

       tax = total*0.17; //calculate the tax on the total price

       due = total + tax; //calculate the price after adding tax

       cout << "        Tax " << " " << tax << endl;

       cout << "-----------------------------------------------" << endl;

       cout << "Amount due      RS " << due << endl;

       cout << "-----------------------------------------------" << endl;

}