CS201 Assignment1 Solution Updated
CS201 Assignment1 Solution Updated
#include <string>
using namespace std;
int main() {
// Hard-coded Name and VU ID
string name = "Muhammad Zulqarnain Haider";
string vuID = "BC240400720";
if (numericPart.length() != 9) {
cout << "Invalid input! Please enter exactly 9 digits." << endl;
return 1;
}
// Quantities
int quantityBurger = extracted[0] - '0';
int quantityPizza = extracted[1] - '0';
int quantityFries = extracted[2] - '0';
int quantitySandwich = extracted[3] - '0';
int quantityDrink = extracted[4] - '0';
// Prices
int priceBurger = 500;
int pricePizza = 1000;
int priceFries = 300;
int priceSandwich = 700;
int priceDrink = 100;
// Subtotals
int subtotalBurger = quantityBurger * priceBurger;
int subtotalPizza = quantityPizza * pricePizza;
int subtotalFries = quantityFries * priceFries;
int subtotalSandwich = quantitySandwich * priceSandwich;
int subtotalDrink = quantityDrink * priceDrink;
// Total Bill
int totalBill = subtotalBurger + subtotalPizza + subtotalFries + subtotalSandwich + subtota
// Discount
double discount = 0;
if (totalBill >= 5000) {
discount = totalBill * 0.10;
}
// Billing Details
cout << "\n--- Billing Details ---\n";
cout << "Item\t\tQuantity\tPrice\tSubtotal\n";
cout << "Burger\t\t" << quantityBurger << "\t\t" << priceBurger << "\t" << subtotalBurger <
cout << "Pizza\t\t" << quantityPizza << "\t\t" << pricePizza << "\t" << subtotalPizza << en
cout << "Fries\t\t" << quantityFries << "\t\t" << priceFries << "\t" << subtotalFries << en
cout << "Sandwich\t" << quantitySandwich << "\t\t" << priceSandwich << "\t" << subtotalSand
cout << "Cold Drink\t" << quantityDrink << "\t\t" << priceDrink << "\t" << subtotalDrink <<
cout << "\nTotal before discount: Rs. " << totalBill << endl;
cout << "Discount: Rs. " << discount << endl;
cout << "Final Payable Amount: Rs. " << finalAmount << endl;
return 0;
}