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

Extreme Level CPP Assignment Part2

Uploaded by

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

Extreme Level CPP Assignment Part2

Uploaded by

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

Extreme Level Programming Assignment – C++ (Part 2)

Question 3: Automated Coffee Vending Machine (15 Marks)

Design a C++ program that simulates a coffee vending machine. The operator should be
able to:
1. Order coffee,
2. Restock items, and
3. Generate a sales report.

Program Requirements

1. Basic Setup:
• Define three drink types:
- Espresso ($5)
- Latte ($7)
- Cappuccino ($8)
• Each starts with 20 cups in stock.
• Declare totalSales to track total income.

2. User Menu:
1 - Order Coffee
2 - Restock
3 - Display Report
4 - Exit

3. Ordering Logic:
• Ask for coffee type (E, L, or C) and quantity.
• If enough stock exists, deduct it and calculate cost.
• Otherwise, display “Out of stock!”

4. Restock Logic:
• Ask for coffee type and quantity.
• Restock only up to a maximum of 30 cups.

5. Report Logic:
• Display remaining cups of each drink and total sales.

6. Exit:
• End program only when option “4” is selected.
Additional Requirements:
1. Use only variables, loops, if-else, and switch statements.
2. Validate all inputs.

Scenario Statement:
A small café uses this program to track sales and stock for its vending machine. When
stock is low, the manager restocks it.

Sample Output:
---- Coffee Machine ----
1. Order Coffee
2. Restock
3. Display Report
4. Exit
Enter choice: 1
Enter Type (E/L/C): L
Enter Quantity: 3
Order successful! Cost: $21
Enter choice: 3
Espresso: 20 cups
Latte: 17 cups
Cappuccino: 20 cups
Total Sales: $21
Question 4: Library Book Management System (15 Marks)

Design a C++ program that manages book borrowing and returns in a small library. The
librarian should be able to:
1. Borrow books,
2. Return books (with fine if late), and
3. Check stock and fine collection.

Program Requirements

1. Basic Setup:
• Declare variables for three book types: Science, Literature, and History.
• Each starts with 10 copies.
• Fine for late return: $5 per day.
• Declare totalFine to track total collected fines.

2. User Menu:
1 - Borrow Book
2 - Return Book
3 - Check Stock
4 - Exit

3. Borrow Logic:
• Ask for book type (S/L/H).
• If stock available, issue the book (reduce by 1).
• Otherwise, show “Not Available.”

4. Return Logic:
• Ask for days late.
• If days > 0, calculate fine = days * $5.
• Add fine to totalFine and increase stock.

5. Report Logic:
• Display remaining copies of each book and total fine collected.

6. Exit:
• Exit only when user chooses option “4”.

Additional Requirements:
1. Use only variables, loops, if-else, and switch statements.
2. Validate inputs and display clear messages.
Scenario Statement:
A school librarian records books issued and returned. If a student returns late, a fine is
charged.

Sample Output:
---- Library Management ----
1. Borrow Book
2. Return Book
3. Check Stock
4. Exit
Enter choice: 1
Enter Book Type (S/L/H): S
Book issued successfully!
Enter choice: 2
Enter Book Type (S/L/H): S
Days late: 3
Fine = $15
Book returned successfully!
Enter choice: 3
Science Books: 10
Literature Books: 10
History Books: 10
Total Fine Collected: $15

You might also like