I have battling to get this task right and I need some assistance: 1.Create a new Python file in this folder called InvestmentCalculator.py 2.At the top of the file include the line: import math 3.Ask the user to input:
The amount that they are depositing, stored as ‘P’. The interest rate (as a percentage), stored as ‘i’. ○ The number of years of the investment. stored as ‘t’. ○ Then ask the user to input whether they want “simple” or “compound” interest, and store this in a variable called ‘interest’.
Only the number of the interest rate should be entered - don’t worry about having to deal with the added ‘%’, e.g. The user should enter 8 and not 8%. ● Depending on whether they typed “simple” or “compound”, output the appropriate amount that they well get after the given period at the interest rate. Look below in “additional information” for the formulae to be used. ● Print out the answer! ● Try enter 20 years and 8 (%) and see what a difference there is depending on the type of interest rate!
Additional Information: ● Don’t forget to cast the input to ints for the calculations! ● ‘r’ below is the interest entered above divided by 100, e.g. if 8% is entered, then r is 0.08. ● Simple interest rate is calculated as follows: ○ A = P(1 + r * t) ○ The Python equivalent is very similar: ■ A =P*(1+rt) ● Compound interest rate is calculated as follows: ○ A = P(1 + r) ^ t ○ The Python equivalent is slightly different: ■ A = P math.pow((1+r),t)
Recent Questions...
ما را در سایت Recent Questions دنبال میکنید
برچسب:
نویسنده: استخدام کار
بازدید: 173
تاريخ: جمعه
14 خرداد
1395 ساعت: 14:28