Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Produce.h #include #include using namespace std; class Produce { protected: string name, origin; double unitPrice; public: Produce(); Produce(string nameIn, string originIn, double price); void setValues(string

image text in transcribed
Produce.h
#include
#include
using namespace std;
class Produce {
protected:
string name, origin;
double unitPrice;
public:
Produce();
Produce(string nameIn, string originIn, double price);
void setValues(string nameIn, string originIn, double price);
string getName();
string getOrigin();
double getUnitPrice();
double getPrice(double lbs);
void display();
};
ostream& operator
*****************************************************
Produce.cpp
#include "Produce.h"
using namespace std;
Produce::Produce() {
// Default values
name = "No name input";
origin = "No origin input";
unitPrice = 0;
}
Produce::Produce(string nameIn, string originIn, double price) {
// Values passed are stored into data members of Produce
name = nameIn;
origin = originIn;
unitPrice = price;
}
void Produce::setValues(string nameIn, string originIn, double price) {
// Values passed are stored into data members of Produce
name = nameIn;
origin = originIn;
unitPrice = price;
}
string Produce::getName() {
return name;
}
string Produce::getOrigin() {
return origin;
}
double Produce::getUnitPrice() {
return unitPrice;
}
double Produce::getPrice(double lbs) {
// Price is the number of pounds times the price per unit
return unitPrice * lbs;
}
void Produce::display() {
// Displays the name, origin, and price per unit of Produce
cout
}
ostream& operator
// Displays the name, origin, and price per unit of Produce
return out
}
Using the provided class Produce you can find it on D2L), create a new class that will inherit from Produce. The child class will be called Fruit. This class will have the following data member: sugarContent. The class will also have its own display function to also display the per unit sugarContent while calling the display function from the parent (see the output), and member function get TotalSugars that will return the total sugar content based on the following equation: sugarContent * pounds Use the following main function to achieve the desired output: #include #include "Produce.h" using namespace std; int main() { Fruit orange("Orange", "Florida", 0.45, 9); Produce apple("Apple", "California", 0.35); double sugars; double pounds=2.5; orange.display(); cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

What attracts you about this role?

Answered: 1 week ago

Question

How many states in India?

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago