Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

Students also viewed these Databases questions

Question

How many multiples of 4 are there between 10 and 250?

Answered: 1 week ago

Question

How many three-digit numbers are divisible by 7?

Answered: 1 week ago

Question

Is the tone of the writing appropriate for the audience?

Answered: 1 week ago

Question

What is the purpose of this document or message?

Answered: 1 week ago