0% found this document useful (0 votes)
7 views

CS201 Assignment

The document is a C++ program that simulates a cafe billing system. It prompts the user to enter the numeric part of their VU-ID, extracts the middle five digits to determine quantities for menu items, and calculates the total bill with an optional discount. Finally, it displays the detailed billing information and thanks the user for their visit.

Uploaded by

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

CS201 Assignment

The document is a C++ program that simulates a cafe billing system. It prompts the user to enter the numeric part of their VU-ID, extracts the middle five digits to determine quantities for menu items, and calculates the total bill with an optional discount. Finally, it displays the detailed billing information and thanks the user for their visit.

Uploaded by

munibahmad012
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <iostream>

#include <string>
using namespace std;

int main() {
// Step 1: Hard-code and display name and VU-ID
string name = "Muneeb Ahmad";
string vuId = "BC240426023";
cout << "NAME: " << name << endl;
cout << "VU-ID: " << vuId << endl << endl;

// Step 2: Ask user to enter the numeric part of VU-ID


string numericVuId;
cout << "Enter numeric part of VU-ID: ";
cin >> numericVuId;

// Step 3: Extract and display the middle 5 digits


string middleDigits = numericVuId.substr(2, 5); // Remove 2 digits from left
and 2 from right
cout << "Extracted Middle Five Digits: " << middleDigits << endl << endl;

// Step 4: Use each digit as quantity for menu items


int quantities[5];
for (int i = 0; i < 5; i++) {
quantities[i] = middleDigits[i] - '0'; // Convert char to int
}

// Step 5: Define menu items and prices


string items[5] = {"Burger", "Pizza", "Fries", "Sandwich", "Cold Drink"};
int prices[5] = {250, 500, 150, 200, 100};
int subtotals[5];

// Step 6: Calculate and display billing details


cout << "========== Welcome to C++ Cafe ==========" << endl;
for (int i = 0; i < 5; i++) {
subtotals[i] = quantities[i] * prices[i];
cout << i + 1 << ". " << items[i] << " (" << quantities[i] << " x Rs. " <<
prices[i] << ") = Rs. " << subtotals[i] << endl;
}

// Step 7: Calculate total bill


int totalBill = 0;
for (int i = 0; i < 5; i++) {
totalBill += subtotals[i];
}

// Step 8: Apply 10% discount if total bill >= 5000


int discount = 0;
if (totalBill >= 5000) {
discount = totalBill * 10 / 100;
cout << endl << "Surprise! You've unlocked a 10% discount" << endl;
}

// Step 9: Display final bill details


cout << endl << "=========== Final Bill ==========" << endl;
cout << "Total before discount: Rs. " << totalBill << endl;
cout << "Discount: Rs. " << discount << endl;
cout << "Net Payable Amount: Rs. " << (totalBill - discount) << endl << endl;
cout << "Thank you for visiting C++ Cafe!" << endl;

return 0;
}

You might also like