Question
Objective: To write a C++ program which shows the proper use of cin, cout, conditional statements if .. else and switch() and loops. Assignment: Write
Objective: To write a C++ program which shows the proper use of cin, cout, conditional statements if .. else and switch() and loops.
Assignment: Write a C++ program that takes you on a Fathers Day shopping spree so you can purchase a gift for your father. The program should allow the user to purchase one of five possible gifts.
The available gifts are:
1. Calvin Klein cologne $68.00
2. A Soft and Cuddly Puppy $39.99
3. A bottle of wine $24.00
4. A frame $16.00
5. A boring old card $ 4.00
Although all the gifts are available, the user should only be shown the choices that he/she can afford along with the choice to buy nothing. Your program should perform the following steps:
1.) Display a Welcome Message
2.) Ask the user if he wants to go on a shopping spree
3.) If the user answers positively:
a) Prompt the user how much money he/she can spend.
b) Display the choices that he/she can afford only.
c) After a choice has been made, the program should print out how much money was spent and how much is still available.
Note: Due to a limited quantity, the user can only purchase one gift at a time. Continue to ask the user if he/she wants to continue shopping as long as they have money available to spend.
Note: They need to have the minimum amount of money necessary and they can purchase the same costume again.
Sample Run of the program (Test Case 1)
>./a.out
How much money do you have to spend? 100
You have enough money to purchase...
1. Calvin Klein cologne, $68 Enter
2. A Soft and Cuddly Puppy, $39.99 Enter
for puppy
3. A bottle of wine, $24 Enter
4. A frame, $16 Enter
5. A boring old card, $4 Enter for boring
6. Nothing Appeals to me, free Enter
Enter from available 6 choice(s) only >> 1
You should choose c, p, w, f, b, n
Would you like to shop some more (y/n)? y
1. Calvin Klein cologne, $68 Enter
2. A Soft and Cuddly Puppy, $39.99 Enter
for puppy
3. A bottle of wine, $24 Enter
4. A frame, $16 Enter
5. A boring old card, $4 Enter for boring
6. Nothing Appeals to me, free Enter for nothing
Enter from available 6 choice(s) only >> c
You have spent $68 and you have $32 left to spend
Would you like to shop some more (y/n)? y
1. A bottle of wine, $24 Enter
2. A frame, $16 Enter
3. A boring old card, $4 Enter for boring
4. Nothing Appeals to me, free Enter
Enter from available 4 choice(s) only >> n
Wise Guy huhh... Would you like to shop some more (y/n)? n
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started