Lab #4 - It’s Valentines Day, let’s go shopping….
Objective: To develop a deeper understanding of conditional logic and use of (if .. else) and switch statments in the C++ programming language. Specifically to show an understanding of the logically appropriate use of single, double, and multiple conditional statements. To reinforce our understanding of data types and variables. Namely, how to create, initialize, display and perform basic arithmetic operations on those variables.
Assignment: Write a program in C++ that allows a customer to go on an on-line Valentine’s Day shopping spree. This is a start-up venture and the stock of our on-line company is currently limited to the following items:
- A bouquet of flowers, $24.00
- A soft and cuddly teddy bear that says “I wuv you”, $39.99
- A box of chocolates, $14.00
- A card, $4.00
Although all items are in stock, the customer should only be made aware of the items that he or she can afford. In addition, demand for our services has been so strong that we can only allow each customer to purchase one item. Each available item has a specific single letter purchase code associated with it. To purchase the desired item, the customer has to enter the specified code. Once the customer places and order, he or she should have the option to receive the reciept via e-mail. Please be aware that there are many customers who just want to waste our precious computer time and will try to go shopping without any money, we cannot allow this.
The program should work as follows:
- Display a welcome message and ask the customer if they are interested in going on a Valentine’s Day Shopping Spree.
If they choose to go shopping,
- Prompt the customer to enter his or her first name and the amount of money they have to spend.
- If they have no money or worse they are in debt and enter a negative amount, just tell them that they need to earn some money first and do not display any choices.
- If they have money to spend, the program should determine which items, if any, they can afford to purchase.
- Each item they can afford should be displayed along with the unique single letter purchase code required to select that item.
- Assuming a purchase can be made (i.e. the customer can afford at least one item), promt the user to enter the purchase code of the item they wish to purchase. You can assume that the customer will only enter a purchase code from the displayed list of options.
- Once the customer has indicated his or her choice, the program should ask the customer if they would like an on-line receipt. The program should then prompt them for their preferred e-mail address or not.
- As a final courtesy, the program should inform the customer how much cash they still have available to spend, just in case they choose to go shopping again.
If they choose not to go shopping, tell the lonely heart that you hope their love life improves so they too can experience the pleasure of over paying on Valdentine’s Day in the near future!
Display the list of choices they can afford using a correct numerical order. Example:
- A bouquet of flowers….
- A soft and cuddly….
- A box of chocolates….
- A card ….
A box of chocolates….
A card ….
Be careful of customer’s who try and pull a fast one and enter a purchase code of an item that was not in their list of choices.
- Display a message after the customer makes a selction that is based on which item they chose. Example, awwwww so sweet, if they purchsse the teddy bear or wonder who is lacking creativity, if they opt for the box of chocolates or well that just says you are a cheapskate, if they opt for the card, etc.
Following is one possible sample run, but feel free to be creative: