Code a program to calculate the time in minutes for someone to cut a yard. Input
ID: 3665954 • Letter: C
Question
Code a program to calculate the time in minutes for someone to cut a yard. Input the length and width of the yard in feet. Input the length and width of the house in feet. Subtract the area of the house from the area of the yard to determine the amount of grass to be cut. Using 2 square feet per second as the rate at which you can cut the grass (set this up as a constant), determine how long it will take someone to mow the lawn, in minutes.
The program should print:
Length and width of yard
Length and width of house
Area to be cut in square feet
Time to mow the yard in minutes
Input data: (run three times):
Yard – 4850 X 6000
House – 1000 X 2000
Please include algorithm amd source
Explanation / Answer
class Lawn{
public static void main(String args[])
{
System.out.println("Widthof the house:");
float hWidth = scanner.nextFloat();
System.out.println("length of the house:");
float hlength = scanner.nextFloat();
System.out.println("Widthof the house:");
float yWidth = scanner.nextFloat();
System.out.println("length of the house:");
float ylength = scanner.nextFloat();
float time = (yLength * yWidth - hLength * hWidth) / 2;
System.out.println("Time:%.3f", time);
}
}