Respuesta :
Answer:
#include<iostream>
using namespace std;
//main function
int main(){
//initialization
float yard_Length,yard_Width;
float house_Length,house_Width;
//display
cout<<"Enter the yard length: "<<endl;
cin>>yard_Length; //store the value
cout<<"Enter the yard width: "<<endl;
cin>>yard_Width; //store the value
cout<<"Enter the house length: "<<endl;
cin>>house_Length; //store the value
cout<<"Enter the house width: "<<endl;
cin>>house_Width; //store the value
//calculate the yard area
float yard_Area = yard_Length*yard_Width;
//calculate the house area
float House_Area = house_Length*house_Width;
//calculate the remaining area
float remain_Yard = House_Area-yard_Area;
//time taking to cut the grass
float time_Taken = remain_Yard/2;
//display output
cout<<"The time taken to cut the grass is: "<<time_Taken<<" seconds"<<endl;
return 0;
}
Explanation:
Include the libraries iostream and stdlib.h for using the input/output instruction and the function abs().
Create the main function and declare the variable.
Print the message on the screen using cout instruction and then store the input enter by the user in the variable using the cin instruction.
we write the above statement four times, two for yard and two for the house.
Then, calculate the area of the yard by the formula.
[tex]Area = length*width[/tex]
The same for calculating the house area.
Then, calculate the remaining area of the yard excluding the house area.
we used the abs() function which defines in the library stdlib.h, it gives the absolute value.
we use the function abs(), because of converting the negative to a positive value.
After that, calculate the time required to cut the grass by divided with the given rate (2 feet per second).
finally, print the output.