roblem #1: [35 pts] Profit calculation for an Avocado farm
Write a program that helps a farmer predict his profit by planting Avocado trees in his land. The farmer is
required to enter the dimensions of his land in meters (rectangular land with a width and length) and the
number of years of prediction. Then, the program will tell him how many trees to plant and a profit
prediction over the specified number of years. Write a program that does this job by knowing the following:
The area of a rectangular shape is: Area = Length x Width.
Each Avocado tree needs 36 m2 of space.
The price of an Avocado tree is 10
Thepriceof1kgofAvocadofruitis3
An Avocado tree starts yielding fruits on the third year (no yield in the first two years), it yields an
average of 7 kg per year. Then, each year it yields 6 times the previous year’s yield. Example: if the
third year’s yield is 7 kg, then the fourth year’s yield is 6 x 7 = 42 kg.
The cost of farming (Workers, water, etc.…) per year is 0.15
foreach1m2Example:Landwidth=100mLandlength=400mNumberofyears=7yearsTheareaofland=400
= 11110
(thisisaone−timepayment)Costoffarmingperyear=0.15x40000=6000
(for the entire land)
Yield calculation:
Year Yield of 1 tree in kg Earning from the entire land
1 and 2 0 0
377kgx3
x 1111 trees = 23331
47x6=4242kgx3
x 1111 trees = 139986
542x6=252252kgx3
x 1111 trees = 839916
6252x6=15121512kgx3
x 1111 trees = 5039496
71512x6=90729072kgx3
x 1111 trees = 30236976
Totalprofit=Totalearning–(Yearlypayment+costofalltrees)=(23331+139986+839916+5039496+30236976)–(7×6000+11110)=36279705
– (42000 + 11110)
= 36279705
–(53110)=36226595
CSCI250 Exam II-v2 Spring 2020-2021
Page 4 of 7
Sample run 1
Enter length & width of your land and the # of years: 100 400 4
Land size = 40000
You need 1111 trees that cost 11110
Earningperyear:year1and2:Yield:0kgEarning:0
year 3:
Yield: 7 kg per tree
Earning: 23331
year4:Yield:42kgpertreeEarning:139986
Total profit = 128207 Misplaced &
Misplaced &
Earning per year:
year 1 and 2:
Yield: 0 kg
Earning: 0
year3:Yield:7kgpertreeEarning:23331
year 4:
Yield: 42 kg per tree
Earning: 139986
year5:Yield:252kgpertreeEarning:839916
year 6:
Yield: 1512 kg per tree
Earning: 5039496
year7:Yield:9072kgpertreeEarning:30236976
Total profit = 36226595 $
Select the correct answer from above options