Project 19: (General Case) Rectangle Efficiency

Suppose you had 30 feet of fencing that could form a rectangle and you wanted to construct a rectangle that produced the most space inside for your livestock.  There are many ways you can form a rectangle with 30 feet.

Way 1: length = 10, width = 5    Area = 50 sq. feet

Way 2: length = 12, width = 3   Area = 36 sq. feet

Way 3: length = 8, width = 7     Area = 56 sq feet

All 3 of these examples use a perimeter of 30 feet but result in different area.  One measure we can use to evaluate how efficient a rectangle is in terms of area and perimeter is by dividing the area by the perimeter.  For this project, we will say a rectangle is efficient if the ratio is greater than 1.5.  

Way 1: length = 10, width = 5    Area = 50 sq. feet      Ratio = 1.667       Efficient = true

Way 2: length = 12, width = 3   Area = 36 sq. feet       Ratio = 1.2            Efficient = false

Way 3: length = 8, width = 7     Area = 56 sq feet         Ratio = 1.867       Efficient = true


Project: Variables 'length' and 'width' have been initialized to unknown values.  Appropriately initialize the value of 'efficient' that represents the ratio of the area to perimeter as explained above.

Note: If your code works for 5 test cases in a row, you can enter your e-mail address.