A farmer has two rectangular fields with a peculiar relationship. Both fields have integer dimensions. The corn field has five times the area of the hay field but the hay field has five times the perimeter of the corn field.
It is also known that the dimensions of the corn field differ by 1, and the shorter dimension of the hay field is less than 100.
Find the dimensions of the two fields.
FOR cornwide = 1 TO 500
cornlong = cornwide + 1
cornarea = cornwide * cornlong
IF cornarea MOD 5 = 0 THEN
hayarea = cornarea / 5
cornperio2 = cornwide + cornlong
hayperio2 = 5 * cornperio2
FOR haywide = 1 TO hayperio2 / 2
haylong = hayperio2 - haywide
IF haywide * haylong = hayarea THEN
PRINT cornwide; cornlong, haywide; haylong
PRINT 2 * (cornwide + cornlong); cornwide * cornlong,
PRINT 2 * (haywide + haylong); haywide * haylong,
_CLIPBOARD$ = STR$(cornwide) + STR$(cornlong) + " " + STR$(haywide) + STR$(haylong) + CHR$(13) + CHR$(10)
_CLIPBOARD$ = _CLIPBOARD$ + STR$(2 * (cornwide + cornlong)) + STR$(cornwide * cornlong)
_CLIPBOARD$ = _CLIPBOARD$ + STR$(2 * (haywide + haylong)) + STR$(haywide * haylong)
249 250 5 2490
perimeter and area:
998 62250 4990 12450
Edited clipboard version of perimeter formula to add needed parentheses. Perimeters appeared correct on screen but added to clipboard for pasting here missed the needed parentheses.
Edited on July 10, 2014, 12:47 pm
Posted by Charlie
on 2014-07-10 11:55:08