Question
You've been hired by Fruit Flies to write a C++ console application that calculates and displays the cost of a customers fruit purchase. Use a
You've been hired by Fruit Flies to write a C++ console application that calculates and displays the cost of a customers fruit purchase. Use a validation loop* to prompt for and get from the user a real-number fruit weight in the range 0.5-4.5 pounds. Prompt for and get from the user a fruit character code per the following table:
Code | Fruit | Cost per pound |
a | Apples | $1.35 |
c | Cherries | $3.40 |
o | Oranges | $1.45 |
s | Strawberries | $2.15 |
Use a switch statementto determine which code was entered. Assume a value of 's' if the user didn't enter one of the four codes. Calculate the cost of the purchase. Format the following five outputs into two formatted columns:
Weight
Fruit code
Fruit name
Fruit cost per pound
Purchase cost
The first column is a left-justified label with units (pounds, $/pound, $, etc.) as needed. The second column is a right-justified value. Format all real numbers to two decimal places. Use formatted output manipulators to print the output. Declare and use constants for the four fruit per pound costs, and the column widths.
* As shown in the session notes and examples in app while statements, a validation loop has form:
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