郊区有一个养猪场和一个马场,其中:猪的总购入价是1万元,饲料费1千元/月,养殖周期1年,售价4万元;马的总购入价是5万元,饲料费3千元/月,养殖周期2年,售价25万元;请根据以上信息,补充合理的假设和参数,构建经营分析模型,分析养猪和养马哪个赚钱?
print("请输入可以用于投资的金额(万元):")
amount = int(input())
n_pig = amount
n_horse = amount
print("请输入投资年限:")
year = int(input())
#猪的收益:
for i in range(1,year+1,1):
n_pig = n_pig//2.2 * 4 + round(n_pig - (n_pig//2.2)*2.2,2)
income_pig = round(n_pig-amount,2) #收入-投资的100万元
#马的收益:
if year == 1: #由于马的投资回报周期为两年,所以投资一年的收益为0
imcome_horse = 0
elif year % 2 == 0:
year_horse = int(year / 2)
for i in range(1,year_horse+1,1):
n_horse = n_horse//8.6 * 25 + round(n_horse - (n_horse//8.6)*8.6,2)
elif year % 2 == 1: #奇数年份,马还未能收益,故与上一年的收益一致
year_horse = int((year - 1) / 2)
for i in range(1,year_horse+1,1):
n_horse = n_horse//8.6 * 25 + round(n_horse - (n_horse//8.6)*8.6,2)
income_horse = round(n_horse - amount,2)
print("投资%d万元,投资%d年,投资猪的收益为:%.2f" %(amount,year,income_pig))
print("投资%d万元,投资%d年,投资马的收益为:%.2f" %(amount,year,income_horse))