Question: Create a class called Peach as follows. Set up two private member variables for ID ( char ) and price ( double ) . Create

Create a class called Peach as follows.
Set up two private member variables for ID (char) and price (double).
Create a public accessor and a public mutator for each member variable.
Create a non-member function outside of the class Peach that takes in an array of Peach objects (Peach) and the size of the array as parameters and returns a Peach object that costs the cheapest price.
Write a C++ program to find the cheapest peach as shown in the test cases.
Notes:
Your program should create an array of Peach objects and call (or use) all the member functions of the Peach objects.
Your program should perform a simple input validation as shown in the test cases.
At the top of your file, your program must include a file name, short description of the program, and your name as a multiple-line C++ comment.
Test Cases:
Enter the number of peaches (1 num6): 1
Enter the number of peaches (1 num6): 6
Enter the number of peaches (1 num6): 3
Enter the ID of Peach 1: X
Enter the price of Peach 1: 2.5
Enter the ID of Peach 2: Y
Enter the price of Peach 2: 1.25
Enter the ID of Peach 3: Z
Enter the price of Peach 3: 3.75
Peach 'x' costs $2.5
COP 2274 C++ Programming for Engineers
Module 7 Individual Coding Assignment (M7ICA): Structures and Classes
Peach 'Y' costs $1.25
Peach 'Z' costs $3.75
The cheapest peach is Peach 'Y' for $1.25
 Create a class called Peach as follows. Set up two private

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!