Question: Assignment: Write a program in C++ that allows a customer to go on-line shopping. This is a start-up venture and the stock of our on-line

Assignment: Write a program in C++ that allows a customer to go on-line shopping. This is a start-up venture and the stock of our on-line company is currently limited to the following items:

A gift card to Home Depot, $50.00

A bottle of cologne (The One by Dolce Gabbana), $24.00

3. Akeychainwithabathtubornament,$14.00 4. Acard,$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 int purchase code associated with it. To purchase the desired item, the customer has to enter the specified code. 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:

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 digit purchase code required to select that item.

Assuming a purchase can be made (i.e. the customer can afford at least one item), prompt 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.

Challenge:

Write a function displayItems that display the list of choices they can afford using a correct numerical order. Think what argument you will need to pass to it. Example: '

AgiftcardtoHomeDepot,$50.00

Abottleofcologne,$24.00

Akeychainwithabathtubornament,$14.00

Acard$4.00

or

3. A key chain with a bathtub ornament, $14.00 4. A card $4.00

getName, returns the user name.

displayItems, displays the items that the user can afford

canAfford, returns true if the user can afford a specific item, false otherwise.

This function should be called from function displayItems.

getChoice, returns the user choice (1-4). This function uses the return value of

function canAfford to determine if the user can afford the item they selected.

shopMore, returns true if the user wishes to continue shopping, false otherwise.

Useconstantstorepresentthepricesofthedifferentitems.

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.

Allow the customer the option of continuing to shop if they still have money

available after making a purchase. Note that this involves implementing a loop.

10.You can write more helper functions.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!