0

Please help to build this Investment Calculator

*amount that they are depositing, stored as ‘P’. *interest rate (as a percentage), stored as ‘i’ *number of years of the investment. stored as ‘t’. *ask the user to input whether they want “simple” or “compound” interest, and store this in a variable called ‘interest’. *interest divided by 100 must be stored as 'r'. *Simple interest is A =P*(1+r*t) *Compound interest rate is calculated A = P* math.pow((1+r),t)

24th Jan 2017, 5:26 PM
Jurie Spies
Jurie Spies - avatar
7 ответов
0
I'm struggling to get the if and elif statement correct for the simple and compound interests.
24th Jan 2017, 6:40 PM
Jurie Spies
Jurie Spies - avatar
0
import math P = float(raw_input('amount depositing ?')) i = float(raw_input('The interest rate in percentage?')) t = float(raw_input('Number of years of investment?')) interest = str(raw_input('\'simple\' or \'compound\' interest ?\n')) r = int((i) / 100) simple = float(P * (1 + r * t)) compound = float(P * math.pow((1 + r), t)) if interest == simple: print (simple) elif interest == compound: print (compound) I get confused with the if elif statements. It does not want to print. Sorry if this is a stupid question. I'm trying really hard to understand python. Want to become a software developer one day.
24th Jan 2017, 6:47 PM
Jurie Spies
Jurie Spies - avatar
0
I wanted to work on python 3 but the online course I'm doing requires me to use 2.7 :( I will try that and get back to you. Thanks so much for helping me
24th Jan 2017, 6:56 PM
Jurie Spies
Jurie Spies - avatar
0
So find new course with python 3)) Use codecademy? Use udacity?))
24th Jan 2017, 6:58 PM
Leshark
Leshark - avatar
0
I payed for this course to get a micro degree. If the course is finished I will definitely go to codecademy.
24th Jan 2017, 7:00 PM
Jurie Spies
Jurie Spies - avatar
- 1
But... you have the instruction how to do it... what's wrong?
24th Jan 2017, 6:34 PM
Leshark
Leshark - avatar
- 2
Wait a minute... Please install python 3 and higher, python 2 is not great) About code: you have unnessesary str() on input(composed or ...) And when you try: if interest == simple You should use "simple", coz input will return str value
24th Jan 2017, 6:48 PM
Leshark
Leshark - avatar