Question

In: Computer Science

Write a Python program that will calculate how much money you will have when you invest...

Write a Python program that will calculate how much money you will have when you invest a given amount of money over a set number of years with a given interest rate. The program takes as user input how much money to invest and the yearly interest rate and calls a calculateEarnings function using those two inputs as the parameters initialMoney and interestRate. Both of the user inputs should be able to be entered in decimal numbers. The calculateEarnings function should print out the amount of money you will have after 1 year, 10 years, 20 years, and 30 years, each value on a new line. The output should be precise to two decimal places. Calculate the total amount of money using compound interest, calculated yearly. The formula for this is below – note that 6% interest would be entered as 0.06 for interestRate in the formula but the user enters it as a percentage in the input: total Money = initial amount * (1 + interest rate)^ number of years. How much money are you investing? 10000 >>>What is the yearly interest rate (%)? 6.0 After 1 year: 10600.00 After 10 years: 17908.48 After 20 years: 32071.35 After 30 years: 57434.91

Solutions

Expert Solution

#Code in text

def calculateEarnings(money,rate):

year=1

amount_after_one = float(money)*(pow((1 + float(rate) / 100.0), year))

print("After 1 ear :%.2f "%amount_after_one)

year=10

amount_after_ten =float(money)*(pow((1 + float(rate) / 100.0), year))

print("After 10 year :%.2f "%amount_after_ten)

year=20

amount_after_twenty =float(money)*(pow((1 + float(rate) / 100.0), year))

print("After 20 year : %.2f"%amount_after_twenty)

year=30

amount_after_thirty =float(money)*(pow((1 + float(rate) / 100.0), year))

print("After 30 year : %.2f"%amount_after_thirty)

#Main

money = input("How much money are you investing? ")

interest_rate=input("What is the yearly interest rate (%)? ")

calculateEarnings(money,interest_rate)

#############################################

#Output

How much money are you investing? 10000
What is the yearly interest rate (%)? 6
After 1 ear :10600.00
After 10 year :17908.48
After 20 year : 32071.35
After 30 year : 57434.91

//Screen shot for indentation


Related Solutions

How much money will you have in 35 years if you invest ​$800 at the beginning...
How much money will you have in 35 years if you invest ​$800 at the beginning of each month at 8.2 percent interest rate being compounded​ semi-annually?
To determine how much money you have to invest, add up the investment for the 4...
To determine how much money you have to invest, add up the investment for the 4 projects. Multiple this total by 80% to get how much money your company has to spend. Choose the best combination of projects for the company to invest in. Show one break even analysis.   Total Investment = $198420.19 Projects: #1 Invest $60000 in a 3D Printer Training and installation $10000 Revenue per year $18000 Cost per year $3000 Market Value year 11 $30000 #2 Invest...
You have $17176 and decide to invest at 3.1% APR compounded monthly. How much money do...
You have $17176 and decide to invest at 3.1% APR compounded monthly. How much money do you have after 9 years?
How much money do you need to invest now, to have $50,000 in 10 years?  Assume an...
How much money do you need to invest now, to have $50,000 in 10 years?  Assume an APR of 4.5%.
you invest 85,000 today in money market. How much will it be worth at the beggining...
you invest 85,000 today in money market. How much will it be worth at the beggining of the 6th year? The appropriate discount rate is 8% compounded quarterly
Starting at age 20, how much money will randy have to invest each month into a...
Starting at age 20, how much money will randy have to invest each month into a Roth IRA in order to have a million dollars by age 65 ? His starting balance is zero
How much do you need to invest today in order to have enough money for your child’s college?
Congratulations, you’ve just become a parent! You want to make sure your new baby has the best education possible so you plan to make an investment today to pay for college. Your new baby is amazing, but is no Doogie Howser, so you will be paying for your child’s college in 18 years from now. You expect that college will cost $100,000 at that time. In the meantime, your financial adviser tells you that you can earn 7% on your...
Assuming you have $28,100 to invest, how much (in $) do you need to invest in the market fund?
You want to create a portfolio with a beta of 1.5. You want to accomplish this goal by investing in a mutual fund that follows the market and in a stock with a beta of 3.0. Assuming you have $28,100 to invest, how much (in $) do you need to invest in the market fund?
Write a program in Python to simulate a Craps game: 1. When you bet on the...
Write a program in Python to simulate a Craps game: 1. When you bet on the Pass Line, you win (double your money) if the FIRST roll (a pair of dice) is a 7 or 11, you lose if it is ”craps” (2, 3, or 12). Otherwise, if it is x ∈ {4, 5, 6, 8, 9, 10}, then your point x is established, and you win when that number is rolled again before ’7’ comes up. The game is...
The following program is to have a time delay. Calculate and tell how much the time...
The following program is to have a time delay. Calculate and tell how much the time delay is. The CPU frequency is 24-MHZ.      org $1000 ; starting address of the program      ldx #80000     ; 2 E cycles loop psha             ; 2 E cycles      pula       ; 3 E cycles      psha       ;      pula       ;      psha       ;      pula       ;      psha       ;      pula       ;      psha       ;      pula       ;      psha       ;     ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT