Docsity

Café Management System: C++ Programming Exercise, Assignments of Computer Programming

Toggle sidebar
bg1
Question 1:
You are required to write a program for a small-scale café management system. The customer can
order any items from following list of menu items.
Code
Meal
Price (PKR)
1
Chicken Karahi
1000
2
Chicken Manchurian with
Egg Fried Rice
900
3
Chicken Biryani
350
4
Seekh Kabab (6pcs/plate)
700
5
Chicken Jalfrezi
850
Implement following modules based on the given criteria:
a. The program should print the code, names and the prices of the dishes that are available in the
menu. The customer can order any dishes using its codes. For example, if the user selects 1
then it means they have ordered Chicken Karahi, similarly, if the customer select 2 then they
ordered chicken Manchurian with egg fried rice and so on. In case of invalid code an error
message will be displayed, and a program will terminate. Make sure that the menu items are
properly formatted using manipulators. [7]
b. Once the dish has been selected, the program should ask the quantity of the item they want to
order. Note that the quantity should be greater than 0. In case of invalid quantity, display an
error message. The program should keep on asking for the quantity unless the correct quantity
is not entered. [4]
c. The customer can select more than one dishes. The program should proceed to the next stage
only if the customer no longer wants to add an item.
d. The program will finally calculate meal price, sales tax on the meal price and the total price of
the meal. For calculating sales tax, please follow the conditions in the given table below: [6]
Meal Price
Applicable Sales Tax
Less than or equal to 1000
0%
Greater than 1000 and less
than or equal to 3000
3%
Greater than 3000
7%
pf3
pf4
pf5

Partial preview of the text

Download Café Management System: C++ Programming Exercise and more Assignments Computer Programming in PDF only on Docsity!

Question 1:

You are required to write a program for a small-scale café management system. The customer can

order any items from following list of menu items.

Code Meal Price (PKR)

1 Chicken Karahi 1000

2 Chicken Manchurian with

Egg Fried Rice

3 Chicken Biryani 350

4 Seekh Kabab (6pcs/plate) 700

5 Chicken Jalfrezi 850

Implement following modules based on the given criteria:

a. The program should print the code, names and the prices of the dishes that are available in the

menu. The customer can order any dishes using its codes. For example, if the user selects 1

then it means they have ordered Chicken Karahi, similarly, if the customer select 2 then they

ordered chicken Manchurian with egg fried rice and so on. In case of invalid code an error

message will be displayed, and a program will terminate. Make sure that the menu items are

properly formatted using manipulators. [7]

b. Once the dish has been selected, the program should ask the quantity of the item they want to

order. Note that the quantity should be greater than 0. In case of invalid quantity, display an

error message. The program should keep on asking for the quantity unless the correct quantity

is not entered. [4]

c. The customer can select more than one dishes. The program should proceed to the next stage

only if the customer no longer wants to add an item.

d. The program will finally calculate meal price, sales tax on the meal price and the total price of

the meal. For calculating sales tax, please follow the conditions in the given table below: [6]

Meal Price Applicable Sales Tax

Less than or equal to 1000 0%

Greater than 1000 and less

than or equal to 3000

Greater than 3000 7%

e. After calculating sales tax, calculate total price of the meal using the following formula: [3]

Total Amount = Meal Price + Sales Tax

f. Lastly, the program will show invoice of the bill that a customer has to pay. The invoice should

also be properly formatted. [5]

Note

Test your code 3 times for different menu items and quantity. Attach screenshot of output for each

execution.

mealName = "Chicken Manchurian with Egg Fried Rice"; mealPrice = 900; } else if (code == 3) { mealName = "Chicken Biryani"; mealPrice = 350; } else if (code == 4) { mealName = "Seekh Kabab (6pcs/plate)"; mealPrice = 700; } else if (code == 5) { mealName = "Chicken Jalfrezi"; mealPrice = 850; } else { cout << "Item is not on the menu." << endl; } cout << endl; int quantity;//user will enter the quantity and it must be more then 0 while (true) { cout << "Enter quantity to order: "; cin >> quantity; if (quantity <= 0) { cout << "Quantity must be greater than 0. Please enter again!" << endl; } else { break; } } cout << endl; // Calculate the total price for the current order totalMealPrice += mealPrice * quantity; orderCount++; //this will ask the user if he wants to order more items string moreItems; cout << "Do you want to order more items? (yes/no): "; cin >> moreItems; if (moreItems != "yes") { break; } } cout << endl; //this will calculate sales tax double salesTax; if (totalMealPrice <= 1000) { salesTax = 0; } else if (totalMealPrice <= 3000) { salesTax = totalMealPrice * 0.03; } else {

salesTax = totalMealPrice * 0.07; } // Calculate total amount double totalAmount = totalMealPrice + salesTax; //using manipulators for invoice cout << endl; cout << setw(25) << "Invoice" << endl; cout << "----------------------------------------------" << endl; cout << setw(5) << "Code" << setw(5) << "|" << setw(5) << "Price(PKR)" << setw(5) << "|" << setw(5) << "Quantity" << setw(5) << "|" << endl; cout << "================================================" << endl; cout << "Meal Price: " << setw(10) << totalMealPrice << " Rs." << endl; cout << "Sales Tax: " << fixed << setprecision(0) << setw(10) << (salesTax * 100 / totalMealPrice) << "%" << endl; cout << "Total Price: " << fixed << setprecision(0) << setw(10) << totalAmount << " Rs." << endl; system("pause"); return 0; }