Cs201 Assignment 1 Solution 2025
Cs201 Assignment 1 Solution 2025
1 Total Marks: 20
nd
Semester: Spring 2025 Due Date: 2 May, 2025
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 given below.
Requirement Instructions:
You are required to Hard-Code your own name and VU ID (e.g., BS123456789) & display it afterwards.
Now, you have to ask a user to enter the numeric part of VU ID.
Extract and display 5 digits from the middle of the numeric part asked in the above step:
o Remove 2 digits from the left and 2 from the right of the 9-digit number.
Each digit of 5 digits extracted in the above step (e.g., 34567) will be used as the quantity for a specific menu item:
o The leftmost is the 1st digit and the rightmost is the 5th digit.
The price of each menu item should be the same as shown in the sample output screenshot below.
Multiply each menu item price by its designated quantity to calculate the total bill.
o Item name
o Unit price
o Discount amount
Note: Remember that if you have not used your name and student id in the program your marks will be deducted.
Solution
#include <iostream>
#include <string>
#include <conio.h>
int main() {
string numeric_part;
if (numeric_part.length() < 7) {
cout << "\nError: Please enter a valid numeric part with at least 7 digits." << endl;
return 1;
cout << "\n\nBurger (" << quantity_burger << " x Rs. " << price_burger << ") = Rs. " << subtotal_burger;
cout << "\nPizza (" << quantity_pizza << " x Rs. " << price_pizza << ") = Rs. " << subtotal_pizza;
cout << "\nFries (" << quantity_fries << " x Rs. " << price_fries << ") = Rs. " << subtotal_fries;
cout << "\nSandwich (" << quantity_sandwich << " x Rs. " << price_sandwich << ") = Rs. " << subtotal_sandwich;
cout << "\nCold Drink (" << quantity_cold_drink << " x Rs. " << price_cold_drink << ") = Rs. " << subtotal_cold_drink;
cout << "\n\nThank you for visiting C++ Cafe!" << endl;
return 0;
Sample Output: