Redo the “Green Fields landscaping with the following modifications “Evergreen T
ID: 3832892 • Letter: R
Question
Redo the “Green Fields landscaping with the following modifications
“Evergreen Tree Pricing Information”
Additionally:
Under 1 foot tall
1 to 3 feet tall
4 to 7 feet tall
8 to 9 feet tall
Over 9 feet tall
Delivery only (per tree)
Delivery + planting
9.00
59.00
89.00
110.00
150.00
30.00
40%
(60.00 max. per order)
Off the cost of the tree.
Do not forget to charge 4.5% taxes on the total cost.
********************************************************************
//ORIGINAL CODE
********************************************************************
// THIS PROGRAM IS USED BY GREEN FIELDS LANDSCAPING TO
//CREATE CUSTOMER INVOICES FOR EVERGREEN TREE SALES.
#INCLUDE <IOSTREAM>
#INCLUDE <IOMANIP>
using namespace std;
int main ()
{
const double PRICE_1 =39.00, // Set prices for different
PRICE_2= 69.00, // size trees
PRICE_3=99.00,
PRICE_4=199.00;
const double PER_TREE_DELIVERY = 20.00, // SET DELIVERY FEES
MAX_DELIVERY=100.00;
int numTrees, // Number of evergreen trees purchaced
height; // Tree height to the nearest foot
char planted, // Are the trees to be planted?('Y'/'N')
delivered; // Are the trees to be delivered?('Y'/'N')
double treeCost, //total price for all the trees
deliveryCost = 0.0, // Delivery cost for all the trees
plantingCost = 0.0, // planting cost for all the trees
totalCharges; // Total invoice amount
// Display Purchace screen and get purchase information
cout <<" Green Fields Landscaping "
<<" Evergreen Tree Purchase ";
cout << " Number of trees purchased:";
cin >> numTrees;
cout << "Tree height to the nearest foot:";
cin >>height ;
cout << "Will Green Fields do the planting?(Y/N):";
cin >>planted;
if (!(planted== 'Y' || planted == 'y'))
{ cout << "Do you want the trees delivered (Y/N):";
cin >> delivered;
}
// Calculate costs
if (height<3)
treeCost = PRICE_1;
else if (height<=5)
treeCost = PRICE_2;
else if (height <=8)
treeCost= PRICE_3
else
treeCost = PRICE_4;
totalTreeCost = numTrees * treeCost;
if (( planted== 'Y') || (planted == 'y'))
plantingCost = totalTreeCost /2;
else if ((delivered == 'Y') || (delivered == 'y'))
if (numTrees<=5)
deliveryCost = PER_TREE_DELIVERY * numTrees;
else
deliveryCost = MAX_DELIVERY;
// ELSE PLANTING AND DELIVERY COSTS BOTH REMAIN 0.0
totalCharges = totalTreeCost + deliveryCost+plantingCost;
// Display information on the invoice
cout << fixed << showpoint << setprecisision(2);
cout << " Green Fields Lanscaping "
<< " Evergreen Tree Purchase ";
cout << setw(2) << numTreees<< " trees @ $" << setw(6) << treeCost
<< " each = $" << setw(8) totalTreeCost << endl;
cout << "Delivery Charge $"
<< setw(8) <<deliveryCost <<endl;
cout << " Planting charge $"
<< setw(8) << planting Cost << endl;
cout << " ___________" <<endl;
cout << "Total Amount Due $"
<< setw(8) << totalCharges << endl << endl;
return 0;
}
Additionally:
Under 1 foot tall
1 to 3 feet tall
4 to 7 feet tall
8 to 9 feet tall
Over 9 feet tall
Delivery only (per tree)
Delivery + planting
9.00
59.00
89.00
110.00
150.00
30.00
40%
(60.00 max. per order)
Off the cost of the tree.
Explanation / Answer
// C++ code
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
const double PRICE_1 =9.00, // Set prices for different
PRICE_2= 59.00, // size trees
PRICE_3=59.00,
PRICE_4=110.00,
PRICE_5=150.00;
const double PER_TREE_DELIVERY = 30.00, // SET DELIVERY FEES
MAX_DELIVERY=60.00,
PLANTING_CONST_PERCENT = 0.4;
int numTrees, // Number of evergreen trees purchaced
height; // Tree height to the nearest foot
char planted, // Are the trees to be planted?('Y'/'N')
delivered; // Are the trees to be delivered?('Y'/'N')
double treeCost, //total price for all the trees
deliveryCost = 0.0, // Delivery cost for all the trees
plantingCost = 0.0, // planting cost for all the trees
totalCharges = 0, // Total invoice amount
totalTreeCost = 0,
tax;
// Display Purchace screen and get purchase information
cout <<" Green Fields Landscaping"
<<" Evergreen Tree Purchase ";
cout << "Number of trees purchased: ";
cin >> numTrees;
cout << "Tree height to the nearest foot: ";
cin >>height ;
cout << "Will Green Fields do the planting?(Y/N): ";
cin >>planted;
if ((planted== 'Y' || planted == 'y'))
{
cout << "Do you want the trees delivered (Y/N): ";
cin >> delivered;
}
// Calculate costs
if (height<1)
treeCost = PRICE_1;
else if (height<=3)
treeCost = PRICE_2;
else if (height <=7)
treeCost= PRICE_3;
else if (height <=9)
treeCost= PRICE_4;
else
treeCost = PRICE_5;
totalTreeCost = numTrees * treeCost;
if ((delivered == 'Y') || (delivered == 'y'))
{
if (numTrees<=60)
deliveryCost = PER_TREE_DELIVERY * numTrees;
else
deliveryCost = MAX_DELIVERY*PER_TREE_DELIVERY + (numTrees- MAX_DELIVERY)*PER_TREE_DELIVERY;
}
//Delivery + planting
if (( planted== 'Y') || (planted == 'y') && (delivered == 'y' || delivered == 'Y'))
plantingCost = totalTreeCost - totalTreeCost*PLANTING_CONST_PERCENT;
// only planting
else if(planted == 'Y' || planted == 'y')
plantingCost = totalTreeCost;
totalCharges = totalTreeCost + deliveryCost + plantingCost;
// charge 4.5% taxes on the total cost.
tax = totalCharges*0.045;
totalCharges = tax + totalCharges;
// Display information on the invoice
cout << fixed << showpoint << setprecision(2);
cout << " Green Fields Lanscaping "
<< " Evergreen Tree Purchase ";
cout << setw(2) << numTrees<< " trees @ $" << setw(6) << treeCost<< " each = $" << setw(8) << totalTreeCost << endl;
cout << "Delivery Charge $" << setw(8) <<deliveryCost <<endl;
cout << "Planting charge $"<< setw(8) << plantingCost << endl;
cout << "Tax: $"<< setw(8) << tax << endl;
cout << "Total Amount Due $"<< setw(8) << totalCharges << endl << endl;
return 0;
}
/*
output:
Green Fields Landscaping Evergreen Tree Purchase
Number of trees purchased: 34
Tree height to the nearest foot: 5
Will Green Fields do the planting?(Y/N): y
Do you want the trees delivered (Y/N): y
Green Fields Lanscaping
Evergreen Tree Purchase
34 trees @ $ 59.00 each = $ 2006.00
Delivery Charge $ 1020.00
Planting charge $ 1203.60
Tax: $ 190.33
Total Amount Due $ 4419.93
*/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.