Description
The purpose of this challenge is to use the IF statement to control program flow. This challenge simulates a simple Point-Of-Sale (POS) system.
Requirements
Feel like a challenge? Go straight to the output without looking at the step-by-step requirements!
- Declare a double variable called cost
- Declare a char variable called is_electronic
- Declare a string variable called item
- Declare a double called fee
- Ask the user to enter a string that describes a single item that is being returned
- Ask the user to enter the cost of the item
- Ask the user if the item is electronic (Ask the user to enter a single character and store this in is_electronic)
- If the item is electronic, calculate restocking fee as 30% of the cost
- Display a friendly summary message and display the appropriate restocking fee as needed
Hints
- Include the <iomanip> header file. This will allow you to use various options to format your output
- It’s good practice to initialize variables to default values that make sense (for example, set fee to 0.00)
- Include the code below before any other cout lines. The setprecision(x) will display your decimal output with x decimal places.
cout << fixed << setprecision(2);
Sample Interaction / Output
-- Welcome to LOSS -- What item are you returning? laptop Cost of laptop? 1200 Is this item electronic (y/n)? y We're bummed you had to make a return. Please pay a restocking fee of $360.00
RUN IT AGAIN:
-- Welcome to LOSS -- What item are you returning? sweater Cost of sweater? 22.99 Is this item electronic (y/n)? n We're bummed you had to make a return. There is no restocking fee.
LEGEND
PROGRAM OUTPUT
USER ENTRY
FROM INPUT
CATALOG ID: CPP-FLOW0002
Print Requirements