Question

USE PYTHON PROGRAMMING LANGUAGE. Compound Interest A high school economics teacher wants to demonstrate the power...

USE PYTHON PROGRAMMING LANGUAGE.

Compound Interest

A high school economics teacher wants to demonstrate the power of compound interest to her students.

She would like you to write a program so that students can input their principal amount and the interest rate they will receive and show them how their investment will grow over time.

The formula to calculate the total income of an investment (compounded annually) over time is:

amount = P (1 + I)<sup>Y</sup>

Where:

  • P is the principal amount (the original amount of the investment)
  • I is the interest rate (Remember! Use the decimal notation - 5% is .05)
  • Y is the amount of time in years

For example: A 10,000 dollar investment at an interest rate of 3.75% for 5 years will be worth 16,105.10 dollars with interest.

  1. Ask your user to provide an investment amount as an integer and save it to an integer variable

    • Your prompt should say "Please enter an amount: "
    • If the input is not an integer, print the message “Error!” and end the program
  2. Ask your user to provide an interest amount as a decimal and save it to a float variable

    • Your prompt should say "Please enter an interest rate: "
    • If the input is not a float, print the message “Error!” and end the program
  3. Write a function named display_interest that takes two arguments: amount and interest_rate.

  4. The body of the function should print the amount the user will have saved with interest every year for a 10 year period

    • No dollar signs or rounding should be used
  5. Call your display_interest function and pass it the user’s inputted values. Print your results to the screen.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
The amount given in the question is incorrect. I checked in an online calculator and my output is matching the online calculator.

Here is the code in python.

=====================================================================================

def display_interest(principal, interest_rate):
    interest_rate /= 100.0
    for year in range(1, 11):
        print('Year:{} Amount User have saved: {}'.format(year, principal * ((1 + interest_rate)**year)))


def main():
    try:
        principal = int(input('Please enter an amount: '))
        interest_rate = float(input('Please enter an interest rate: '))
        display_interest(principal, interest_rate)
    except:
        print('Error!')

main()

========================================================================

Add a comment
Know the answer?
Add Answer to:
USE PYTHON PROGRAMMING LANGUAGE. Compound Interest A high school economics teacher wants to demonstrate the power...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming language: PYTHON Prompt: You will be creating a program to show final investment amounts from...

    Programming language: PYTHON Prompt: You will be creating a program to show final investment amounts from a principal using simple or compound interest. First, get a principal amount from the user. Next, ask the user if simple or compound interest should be used. If the user types in anything other than these options, ask again until a correct option is chosen. Ask the user to type in the interest rate as a percentage from 0 to 100%. Finally, ask the...

  • Write a program in Python that computes the interest accrued on an account. You can modify...

    Write a program in Python that computes the interest accrued on an account. You can modify the “futval.py” program given in Chapter 2 to accomplish it. Your program should use a counted loop rather than a formula. It should prompt the user to enter the principal amount, the yearly interest rate as a decimal number, the number of compounding periods in a year, and the duration. It should display the principal value at the end of the duration. To compute...

  • 14.Compound Interest hank account pays compound interest, it pays interest not only on the principal amount...

    14.Compound Interest hank account pays compound interest, it pays interest not only on the principal amount that was deposited into the account, but also on the interest that has accumulated over time. Suppose you want to deposit some money into a savings account, and let the account earn compound interest for a certain number of years. The formula for calculating the balance of the account afer a specified namber of years is The terms in the formula are A is...

  • Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anythi...

    Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anything. No code outside of a function! Median List Traversal and Exception Handling Create a menu-driven program that will accept a collection of non-negative integers from the keyboard, calculate the mean and median values and display those values on the screen. Your menu should have 6 options 50% below 50% above Add a number to the list/array...

  • This is a quick little assignment I have to do, but I missed alot of class...

    This is a quick little assignment I have to do, but I missed alot of class due to the Hurricane and no one here knows what theyre doing. please help! this is Java with intelli-J Overview In this project students will build a four-function one-run calculator on the command line. The program will first prompt the user for two numbers, then display a menu with five operations. It will allow the user to select an option by reading input using...

  • Intro to Programming and Logic: Python 2, Chapter 8 – Strings (so far have learned the...

    Intro to Programming and Logic: Python 2, Chapter 8 – Strings (so far have learned the way of a program, variables, expressions, statements, functions, interface design, conditional, recursion and iteration) Write a program that takes a string as a parameter. It will analyze the string and return True if it is a valid float number. It will return False if it is not a valid float value. Your function should return True in any of these cases: 0.17, .17, 5.27,...

  • . Use what you learned from our First Python Program to write a Python program that...

    . Use what you learned from our First Python Program to write a Python program that will carry out the following tasks. Ask user provide the following information: unit price (for example: 2.5) quantity (for example: 4) Use the following formula to calculate the revenue: revenue = unit price x quantity Print the result in the following format on the console: The revenue is $___. (for example: The revenue is $10.0.) . . Use the following formula to calculate the...

  • In this assignment you are asked to write a python program to maintain the Student enrollment...

    In this assignment you are asked to write a python program to maintain the Student enrollment in to a class and points scored by him in a class. You need to do it by using a List of Tuples What you need to do? 1. You need to repeatedly display this menu to the user 1. Enroll into Class 2. Drop from Class 3. Calculate average of grades for a course 4. View all Students 5. Exit 2. Ask the...

  • Create a Java Program/Class named ComputeInterest to calculate compound interest. This can all be done entirely...

    Create a Java Program/Class named ComputeInterest to calculate compound interest. This can all be done entirely in the main() method. Create a double variable named currentBalance. Create a double variable named newBalance. Create a final double variable named INTEREST_RATE and assign 1.05 to it. Create a int variable named yearCount. Prompt for the "Number of years to invest" and store the input into the yearCount variable. Prompt for the "Amount to Invest" and store this in the currentBalance variable. Assign...

  • %%Python Question%% get_min_payment() • Parameters ◦ the total amount of the mortgage (called the principal; should...

    %%Python Question%% get_min_payment() • Parameters ◦ the total amount of the mortgage (called the principal; should be a positive number) ◦ the annual interest rate (should be a float between 0 and 1) ◦ the term of the mortgage, in years (should be a positive integer; default value: 30) ◦ the number of payments per year (should be a positive integer; default value: 12) • Functionality ◦ Compute the minimum mortgage payment. Should use the formula A= Pr(1+r) n (1+r)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT