I cannot figure out if this is right because there is no example to verify calculations and I have gone over this a few hours now. I do not need help with programming, just the correct mathematics.

"Your kid brother plans to start a lawn-mowing service this summer, and he wants to earn $10 per hour.

The input is (in feet) the length and width of a rectangular yard and the length and width of the house situated in the yard.

All input is in feet. His average speed for mowing is .20 square yards per second. The amount to charge the customer should be printed as output."

Here is what I have:

 MowYardsPerHour = .20 * 60 * 60;
 MowRate = 10;

 houseLength = houseLength /3;
 houseWidth = houseWidth /3;

 yardLength = yardLength /3;
 yardWidth = yardWidth /3;

 squareYdYard = yardLength * yardWidth;
 squareYdHouse = houseLength * houseWidth;

 mowRange = squareYdYard - squareYdHouse;

 amountDue = (mowRange / MowYardsPerHour) * MOW_RATE;

Is this right way to calculate the rate??

  • 1
    $\begingroup$ The names of the variables are a little peculiar, and likely to cause confusion. The basic formula is correct, though needlessly complicated. Why not convert the mow rate to square feet per hour? $\endgroup$ – André Nicolas Sep 23 '13 at 4:12
  • $\begingroup$ Seems correct to me. Amount that should be paid is the mowRate times the total area mowed divided by area that can be mowed in an hour. $\endgroup$ – Sudarsan Sep 23 '13 at 4:13
  • $\begingroup$ Thanks, this is what I was wondering. I looked at this program so many time I just got confused. $\endgroup$ – Hermes Trismegistus Sep 23 '13 at 4:22

The method is right. I would suggest rewriting the program so that one works purely in feet and square feet. That makes the four conversions to square yards unnecessary. The mow rate is $(9)(0.2)(60)(60)$ square feet per hour. Let $x$ and $y$ be the overall lot dimensions in feet, and $a$ and $b$ the house dimensions in feet. Then we charge $$\frac{xy-ab}{(9)(0.2)(3600)}\times 10.$$

Remarks: $1.$ But I am not a good one for business advice. The printout from the longer program may be more impressive.

$2.$ It is good practice to use names for the inputs that are more informative than the ones used in the answer.

  • $\begingroup$ Genius. Wish I could have seen this. $\endgroup$ – Hermes Trismegistus Sep 23 '13 at 4:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.