Answered step by step
Verified Expert Solution
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
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
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 #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
*****************************************************
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
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 }
ostream& operator
// Displays the name, origin, and price per unit of Produce
return out
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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