Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program for a clerk of Fresh Fruit Store so that the clerk will input the items that a customer buys and then print
- Write a program for a clerk of Fresh Fruit Store so that the clerk will input the items that a customer buys and then print out the name, unit price, quantity, and cost of all item and the total cost as a receipt.
The program should do the following:
- Define a new data type, fruit, as a C++ class. The class fruit should include:
- The name of the fruit in an item. Ex: Apple, Banana, ..
- The unit price of the fruit in the item. Ex: 0.99 ($/lb), 1.29 ($/lb), .
- The quantity of the fruit that the customer buys. Ex. 2 lbs, 3.5 lbs, ..
- Set the name, unit price, and quantity of the fruit in the item.
- Set the name of the fruit in the item only.
- Set the unit price of the fruit in the item only.
- Set the quantity of the fruit in the item only.
- Return the name of the fruit in the item.
- Return the unit price of the fruit in the item.
- Return the quantity of the fruit in the item.
- Return the cost of the item. (cost = unit price * quantity)
- Constructor with three default value
name = , unit price = 0.0, quantity = 0.0.
- Overloading the operator << to print the item in the following format:
Ex:
Apple $0.99/lb 3 lb $2.97
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