Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part II A landscaping company needs a program to cost out sodding and fencing fo

ID: 3815064 • Letter: P

Question

Part II

A landscaping company needs a program to cost out sodding and fencing for an area, given the length and width in feet. Sod is 47 cents a square foot and fencing is $22.50 a foot.

Part II will produce 2 files.

Pricing.h file is the Pricing class (derived from the Geometry class - the parent class) with its members and functions.

The main cpp file uses the code in the Pricing/Geometry classes.

Here is the format of Pricing.h class. See Display 10.9.

#include "Geometry.h"                   //Includes the code from Geometry.h

class Pricing : Geometry                  //Pricing is derived from the Geometry class

{

public:

                  constructor

                            Invokes the Geometry constructor.

                   getSodCost function

                                        § receives the price.

                                        § Uses the getArea function in the Geometry class.

                                        § Returns the area times price.

                 getFenceCost function:

                                         ·. Receives the price.

                                         · Uses the getPerimeter function in the Geometry class.

                                         · Returns the perimeter times price.

        private:

        };

            //Function headers and code

Parkton Landscaping Enter length: in Enter width: 12 Landscaping Costs Sod 56 40 Fence 994

Explanation / Answer

//File1: Geometry.h

#ifndef GEOMETRY_H
#define GEOMETRY_H

typedef int BOOL;
enum { FALSE, TRUE };

class Geometry
{
public:
Geometry();
Geometry(float area, float perimeter);
float getArea();
BOOL setArea(float value);
float getPerimeter();
BOOL setPerimeter(float value);
protected:
float area;
float perimeter;
};
#endif

//File2: Geometry.cpp

#include "Geometry.h"

Geometry:: Geometry()
{
}
Geometry::Geometry(float areaValue, float perimeterValue)
{
area = areaValue;
perimeter = perimeterValue;
}
float Geometry::getArea()
{
return area;
}
BOOL Geometry::setArea(float value)
{
area = value;
return 1;
}
float Geometry::getPerimeter()
{
return perimeter;
}
BOOL Geometry::setPerimeter(float value)
{
perimeter = value;
return 1;
}

//File 3: Pricing.h

#ifndef PRICING_H
#define PRICING_H
#include "Geometry.h"

class Pricing: public Geometry
{
public:
Pricing();
Pricing(float sodCostUnitPrice, float fenceCostUnitPrice);
float getSodCost(float sodCostUnitPrice);
float getFenceCost(float fenceCostUnitPrice);

private:
float sodCostUnitPrice;
float fenceCostUnitPrice;

};

#endif

//File 4: Pricing.cpp

#include "Geometry.h"
#include "Pricing.h"

Pricing:: Pricing(){ }

Pricing:: Pricing(float value1, float value2)
{
sodCostUnitPrice = value1;
fenceCostUnitPrice = value2;
}

float Pricing:: getSodCost(float unitPrice)
{
float totalCost = unitPrice * area;
return totalCost;
}

float Pricing:: getFenceCost(float unitPrice)
{
float totalCost = unitPrice * perimeter;
return totalCost;
}

//File 5: Main.cpp

#include <iostream>
#include "Geometry.h"
#include "Pricing.h"

using namespace std;

int main()
{
Geometry geometry;
float length, width, sodArea, perimeter;
float sodUnitPrice, fenceUnitPrice;
cout << "Enter the Length: ";
cin >> length;
cout << "Enter the Width: ";
cin >> width;
sodArea = length * width;
//cout << "Enter the fencing perimeter length: ";
//cin >> perimeter;
perimeter = 2 * (length + width);
geometry(sodArea, perimeter);
cout << "Enter the sod unit price: ";
cin >> sodUnitPrice;
cout << "Enter the fencing Unit price: ";
cin >> fenceUnitPrice;
Pricing pricing(sodUnitPrice, fenceUnitPrice);
float totalSodCost = pricing.getSodCost(sodUnitPrice);
float totalFenceCost = pricing.getFenceCost(fenceUnitPrice);

cout << "Total sod cost = " << totalSodCost;
cout << "Total Fence cost = " << totalFenceCost;
return 0;
}