0% found this document useful (0 votes)
97 views4 pages

Assignment Cs 210

The document is a C++ program that simulates a cafe ordering system. It prompts the user for a numeric part of their VU-ID, extracts the middle five digits to determine quantities of menu items, calculates the total bill, and applies a discount if applicable. Finally, it displays the order details and the final payable amount.

Uploaded by

Aiman Afzal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views4 pages

Assignment Cs 210

The document is a C++ program that simulates a cafe ordering system. It prompts the user for a numeric part of their VU-ID, extracts the middle five digits to determine quantities of menu items, calculates the total bill, and applies a discount if applicable. Finally, it displays the order details and the final payable amount.

Uploaded by

Aiman Afzal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include <iostream>

#include <string>

using namespace std;

int main() {

// Student info

string name = "Ayesha Waheed";

string vuID = "BC250223146";

// Display name and ID

cout << "Name: " << name << endl;

cout << "VU-ID: " << vuID << endl;

// Ask user for numeric part of VU ID

string numericPart;

cout << "\nEnter numeric part of VU-ID: ";

cin >> numericPart;

// Validate input length

while ([Link]() != 9) {

cout << "Invalid input. Please enter exactly 9 digits: ";

cin >> numericPart;

// Extract middle 5 digits

string middleFive = [Link](2, 5);

cout << "\nExtracted Middle Five Digits: " << middleFive << endl;

// Prices
int priceBurger = 250;

int pricePizza = 500;

int priceFries = 150;

int priceSandwich = 200;

int priceDrink = 100;

// Quantities

int qtyBurger = middleFive[0] - '0';

int qtyPizza = middleFive[1] - '0';

int qtyFries = middleFive[2] - '0';

int qtySandwich = middleFive[3] - '0';

int qtyDrink = middleFive[4] - '0';

// Subtotals

int totalBurger = qtyBurger * priceBurger;

int totalPizza = qtyPizza * pricePizza;

int totalFries = qtyFries * priceFries;

int totalSandwich = qtySandwich * priceSandwich;

int totalDrink = qtyDrink * priceDrink;

int totalBill = totalBurger + totalPizza + totalFries + totalSandwich + totalDrink;

float discount = 0.0;

float netAmount = totalBill;

if (totalBill >= 5000) {

discount = totalBill * 0.10;

netAmount = totalBill - discount;

}
// Display Menu and Details

cout << "\n=== Welcome to C++ Cafe ===\n";

cout << "------ MENU ------\n";

cout << "1. Burger - Rs. " << priceBurger << endl;

cout << "2. Pizza - Rs. " << pricePizza << endl;

cout << "3. Fries - Rs. " << priceFries << endl;

cout << "4. Sandwich - Rs. " << priceSandwich << endl;

cout << "5. Cold Drink - Rs. " << priceDrink << endl;

cout << "\nBurger (" << qtyBurger << " x Rs. " << priceBurger << ") = Rs. " << totalBurger << endl;

cout << "Pizza (" << qtyPizza << " x Rs. " << pricePizza << ") = Rs. " << totalPizza << endl;

cout << "Fries (" << qtyFries << " x Rs. " << priceFries << ") = Rs. " << totalFries << endl;

cout << "Sandwich (" << qtySandwich << " x Rs. " << priceSandwich << ") = Rs. " << totalSandwich <<
endl;

cout << "Cold Drink (" << qtyDrink << " x Rs. " << priceDrink << ") = Rs. " << totalDrink << endl;

// Discount message

if (totalBill >= 5000) {

cout << "\nSurprise! You've unlocked a 10% discount!" << endl;

// Final Bill

cout << "\n===== Final Bill =====" << endl;

cout << "Total before discount: Rs. " << totalBill << endl;

cout << "Discount: Rs. " << discount << endl;

cout << "Net Payable Amount: Rs. " << netAmount << endl;

cout << "\nThank you for visiting C++ Cafe!" << endl;
return 0;

Sample Output (For Input: 250223146)

Name: Ayesha Waheed


VU-ID: BC250223146

Enter numeric part of VU-ID: 250223146

Extracted Middle Five Digits: 02231

=== Welcome to C++ Cafe ===


------ MENU ------
1. Burger - Rs. 250
2. Pizza - Rs. 500
3. Fries - Rs. 150
4. Sandwich - Rs. 200
5. Cold Drink - Rs. 100

Burger (0 x Rs. 250) = Rs. 0


Pizza (2 x Rs. 500) = Rs. 1000
Fries (2 x Rs. 150) = Rs. 300
Sandwich (3 x Rs. 200) = Rs. 600
Cold Drink (1 x Rs. 100) = Rs. 100

===== Final Bill =====


Total before discount: Rs. 2000
Discount: Rs. 0
Net Payable Amount: Rs. 2000

Thank you for visiting C++ Cafe!

You might also like