In: Computer Science
Please assist me with this C++ problem.
Lawn Mowing Company: A lawn mowing company offers to mow one acre of grass for $150. An acre equals 43,450 square feet. There are 3 feet in a yard. And, a standard soccer field, with buffer for the sidelines is about 140 yards by 100 yards. How much would it cost to hire this company to mow the one soccer field? Assume that the company does calculate for partial acres. Write a program to calculate the total cost and display it to the screen. Starter code has been provided for this problem:
https://www.onlinegdb.com/r15z8TfE4
Program.cpp:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
const int sq_ft_per_acre = 43450;
const int ft_per_yd = 3;
float cost_per_acre = 150.0;
float field_width = 100; // width in yards
float field_length = 140; // length in yards
int sq_ft_per_field;
float num_acres;
float total_cost;
// Using what you know about units and calculating area, finish the
following
// statement to determine the number of square feet of the
field.
sq_ft_per_field = field_width*ft_per_yd * field_length *
ft_per_yd;
// Now, determine the number of acres in the field.
num_acres = (float)sq_ft_per_field/sq_ft_per_acre;
// Now, determine the cost to mow the field.
total_cost = num_acres * cost_per_acre;
std::cout<< std::fixed<<std::setprecision(2);// used to
format output to 2 decimals
std::cout<<"Total cost to mow a soccer field:
"<<total_cost<<endl;
// And, finally, display the cost. Ideally, you should format this
so it only
// shows two decimal places. Study the output formatting section in
the lecture
// notes - and, if needed, including a new library above.
}
Output: