CSC212 - Assignment 2 - Spring 2024
CSC212 - Assignment 2 - Spring 2024
Collaboration Policy:
This assignment must be performed individually
Due Date:
The assignment is due on Sunday March 24 by 11:59 PM. Late Submission will not be accepted.
Deliverables:
Please use Blackboard to submit your assignment. You should submit:
.cpp file containing your code.
Objective:
The objective of this assignment is to get familiar with C++ programming language and control statements.
Notes:
You are required to use comments to explain what you’re doing.
You must only use the concepts we took in chapters 2, 4, 5.
You should write a program that lets a customer choose the items he/she wants to buy, and the
quantity of each item and get how much money he/she should pay. Suppose the available items
and their unit prices are the following:
Item Price
Twix 1.25$
Snickers 1.50$
Kit Kat 1.00$
Leo 0.75$
Juice 1.00$
The program should display a menu in a tabular format, allowing the users to choose which
item they desire to buy.
(Each item corresponds to a number that should be entered by the user, for example: 1 for Twix,
2 for Snickers, etc...). You should use a switch structure.
When the user enters his/her choice, the program should ask for the desired quantity from this
item, and then it should calculate the total money that should be paid for this item.
The program should then ask the user to choose another item, along with its quantity (Note that
the user can choose the same item again!). The program stops when the user enters -1.
When the user finishes his/her choices, the program should display the following:
The quantity chosen from each item, and the price relative to this quantity.
The total number of items bought.
The total amount of money that should be paid.
If more than 15 items were bought, a discount of 10% should be given, and the program
should display the cost after the discount.
NB:
1. Note that all decimal numbers should stick to only 2 decimal points.
2. Note that you should validate the inputs of the user, i.e. when choosing the type of items,
the user should not enter an invalid value, and when entering the quantity make sure it’s a
positive number (You can’t input 0 quantity).
3. When the program finishes, do not display the items with quantity = 0, and display them
in a tabular format as shown in the sample output.