0% found this document useful (0 votes)
16 views3 pages

CS201 Spring 20250

Uploaded by

ch9651146
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)
16 views3 pages

CS201 Spring 20250

Uploaded by

ch9651146
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
You are on page 1/ 3

Student Id:bc240205738

Course: CS201

Semester: Spring2025

Problem Statement:

Write a C++ program that uses items price from a menu and your VU ID to
calculate the total and net bills according to the requirements .

Solution: #include <iostream>

#include <string>

#include <iomanip>

Using namespace std;

Int main() {

// Hard-coded Name and VU ID

String name = “Ali Ahmed”;

String vuID = “BS123456789”;

Cout << “Name: “ << name << endl;

Cout << “VU ID: “ << vuID << endl;

// Ask user to enter numeric part of VU ID

String numericID;

Cout << “Enter the 9-digit numeric part of your VU ID: “;

Cin >> numericID;

// Extract 5 middle digits (remove first 2 and last 2)

String middleDigits = numericID.substr(2, 5);

Cout << “Extracted Middle Digits: “ << middleDigits << endl;


// Convert each character to integer quantity

Int quantities[5];

For (int I = 0; I < 5; ++i) {

Quantities[i] = middleDigits[i] – ‘0’; // Convert char to int

// Menu Items and Prices

String items[5] = {“Burger”, “Pizza”, “Fries”, “Sandwich”, “Cold Drink”};

Int prices[5] = {500, 800, 300, 400, 100};

// Display Billing Info

Int total = 0;

Cout << “\n----- BILLING DETAILS -----\n”;

Cout << left << setw(15) << “Item”

<< setw(10) << “Qty”

<< setw(12) << “Unit Price”

<< setw(12) << “Subtotal” << endl;

For (int I = 0; I < 5; ++i) {

Int subtotal = quantities[i] * prices[i];

Total += subtotal;

Cout << left << setw(15) << items[i]

<< setw(10) << quantities[i]

<< “Rs. “ << setw(7) << prices[i]

<< “Rs. “ << subtotal << endl;

}
// Calculate Discount

Double discount = 0;

If (total >= 5000) {

Discount = total * 0.10;

Double netTotal = total – discount;

// Display Summary

Cout << “\nTotal Bill (Before Discount): Rs. “ << total << endl;

Cout << “Discount: Rs. “ << discount << endl;

Cout << “Final Payable Amount: Rs. “ << netTotal << endl;

Return 0;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy