Need assistance with python code. Problem statement:   Design the solution to the following problem and implement it in a Python program. Implement a program that allows the user to choose from a menu to calculate the future value of an investment, the present value (how much you need to invest) for a target investment value, or the monthly payment for a loan.  The formulas for these quantities are given as follows:   A:  amount (present value, target value, or loan amount depending on what is calculated) r:  interest rate (Note: the user will enter 3.5 for 3.5%. When substituting in the formula, the user input needs to be decimal, that is, 0.035 which is 3.5/100 t=  time (number of years for the investment or the loan) (See attached image for reference)     Your program will provide a menu to the user with the following options:   F - Future Value P - Present Value M- Monthly Payment Q - Quit   If the user chooses F, P, or M (or lowercase versions of these letters), then the program will perform the necessary action(s) (see below) and then display the menu again to get the user's choice.   If the user chooses Q or q then the program will display a "Good Bye" message and end.   If the user chooses any other key, the program will print "Invalid input" on the screen and display the menu again to get user's choice.   In this program you are required to implement 4 functions: displayMenu() This function will be called to display the menu. It will print a menu as shown above. (Note that it has no parameters and no return)   calculateFutureValue(amount,interest_rate,duration)   This function will be called if the user chooses option F. It will calculate the future value for the given parameters and return the future value.  (This function does NOT print anything. It does NOT ask the user for input)   calculatePresentValue(amount,interest_rate,duration)   This function will be called if the user chooses option P. It will calculate the present value for the given parameters and return the present value.  (This function does NOT print anything. It does NOT ask the user for input) calculateMonthlyPayment(loan_amount, interest_rate, duration)   This function will be called if the user chooses option M. It will calculate the monthly payment of a loan for the given parameters and return the monthly payment.  (This function does NOT print anything. It does NOT ask the user for input)   Here is the code that I have: def displayMenu():     print("Welcome to your financial calculator!")     print("F - Future Value")     print("P - Present Value")     print("M - Monthly Payment")     print("Q - Quit")     return str(input("Please select on of the options above: ")) def calculateFutureValue(amount, interest_rate, duration):     FutureValue = amount * ( 1 + interest_rate) ** duration     #print("Future value of your investment is", round(FutureValue, 2))     return round(FutureValue, 2) def calculatePresentValue(amount, interest_rate, duration):     PresentValue = amount * ( 1 + interest_rate) ** -duration     #print("Present value of your target amount is", round(PresentValue, 2))     return round(PresentValue, 2) def calculateMonthlyPayment(loan_amount, interest_rate, duration):     MonthlyPayment = (Amount * (interest_rate/12) * (1 + (interest_rate/12)) ** duration *12) / ((1 + (interest_rate/12))**duration * 12 - 1)     #print("Monthly payment for your loan is", round(MonthlyPaymnet, 2))     return round(MonthlyPayment, 2) def main():     while True:         choice = displayMenu()         if choice == ["F"] or ["f"]:             amount = float(input(print("Please enter the investment amount:")))             interest_rate = float(input(print("Please enter the interest rate:")))             duration = float(input(print("For how many years will you invest?:")))             calculateFutureValue(amount, interest_rate, duration)             print("Future value of your investment is", FutureValue)         elif choice == ["P"] or ["p"]:             amount = float(input(print("Please enter the target amount:")))             interest_rate = float(input(print("Please enter the interest rate:")))             duration  = float(input(print("In how many year you want to hit the target?")))             calculatePresentValue(amount, interest_rate, duration)             print("Present value of your target amount is", PresentValue)         elif choice == ["M"] or ["m"]:             loan_amout = float(input(print("Please enter the loan amount:")))             interest_rate = float(input(print("Please enter the interest rate:")))             duration = float(input(print("In how many years wil you pay?")))             calculateMonthlyPayment(loan_amount, interest_rate, duration)             print("Monthly payment for your loan is", MonthlyPaymnet)         elif choice == ["Q"] or ["q"]:             print("Thank you for using my financial calculator!")             break         else:             print("Invalid Option")             break main()

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Need assistance with python code.

Problem statement:

 

Design the solution to the following problem and implement it in a Python program.

Implement a program that allows the user to choose from a menu to calculate the future value of an investment, the present value (how much you need to invest) for a target investment value, or the monthly payment for a loan.  The formulas for these quantities are given as follows:

 

A:  amount (present value, target value, or loan amount depending on what is calculated)

r:  interest rate (Note: the user will enter 3.5 for 3.5%. When substituting in the formula, the user input needs to be decimal, that is, 0.035 which is 3.5/100

t=  time (number of years for the investment or the loan) (See attached image for reference)

 

 

Your program will provide a menu to the user with the following options:

 

F - Future Value

P - Present Value

M- Monthly Payment

Q - Quit

 

  • If the user chooses F, P, or M (or lowercase versions of these letters), then the program will perform the necessary action(s) (see below) and then display the menu again to get the user's choice.

 

  • If the user chooses Q or q then the program will display a "Good Bye" message and end.

 

  • If the user chooses any other key, the program will print "Invalid input" on the screen and display the menu again to get user's choice.

 

In this program you are required to implement 4 functions:

  1. displayMenu()

This function will be called to display the menu. It will print a menu as shown above. (Note that it has no parameters and no return)

 

  1. calculateFutureValue(amount,interest_rate,duration)

 

This function will be called if the user chooses option F. It will calculate the future value for the given parameters and return the future value.  (This function does NOT print anything. It does NOT ask the user for input)

 

  1. calculatePresentValue(amount,interest_rate,duration)

 

This function will be called if the user chooses option P. It will calculate the present value for the given parameters and return the present value.  (This function does NOT print anything. It does NOT ask the user for input)

  1. calculateMonthlyPayment(loan_amount, interest_rate, duration)

 

This function will be called if the user chooses option M. It will calculate the monthly payment of a loan for the given parameters and return the monthly payment.  (This function does NOT print anything. It does NOT ask the user for input)

 

Here is the code that I have:

def displayMenu():

    print("Welcome to your financial calculator!")

    print("F - Future Value")

    print("P - Present Value")

    print("M - Monthly Payment")

    print("Q - Quit")

    return str(input("Please select on of the options above: "))

def calculateFutureValue(amount, interest_rate, duration):

    FutureValue = amount * ( 1 + interest_rate) ** duration

    #print("Future value of your investment is", round(FutureValue, 2))

    return round(FutureValue, 2)

def calculatePresentValue(amount, interest_rate, duration):

    PresentValue = amount * ( 1 + interest_rate) ** -duration

    #print("Present value of your target amount is", round(PresentValue, 2))

    return round(PresentValue, 2)

def calculateMonthlyPayment(loan_amount, interest_rate, duration):

    MonthlyPayment = (Amount * (interest_rate/12) * (1 + (interest_rate/12)) ** duration *12) / ((1 + (interest_rate/12))**duration * 12 - 1)

    #print("Monthly payment for your loan is", round(MonthlyPaymnet, 2))

    return round(MonthlyPayment, 2)

def main():

    while True:

        choice = displayMenu()

        if choice == ["F"] or ["f"]:

            amount = float(input(print("Please enter the investment amount:")))

            interest_rate = float(input(print("Please enter the interest rate:")))

            duration = float(input(print("For how many years will you invest?:")))

            calculateFutureValue(amount, interest_rate, duration)

            print("Future value of your investment is", FutureValue)

        elif choice == ["P"] or ["p"]:

            amount = float(input(print("Please enter the target amount:")))

            interest_rate = float(input(print("Please enter the interest rate:")))

            duration  = float(input(print("In how many year you want to hit the target?")))

            calculatePresentValue(amount, interest_rate, duration)

            print("Present value of your target amount is", PresentValue)

        elif choice == ["M"] or ["m"]:

            loan_amout = float(input(print("Please enter the loan amount:")))

            interest_rate = float(input(print("Please enter the interest rate:")))

            duration = float(input(print("In how many years wil you pay?")))

            calculateMonthlyPayment(loan_amount, interest_rate, duration)

            print("Monthly payment for your loan is", MonthlyPaymnet)

        elif choice == ["Q"] or ["q"]:

            print("Thank you for using my financial calculator!")

            break

        else:

            print("Invalid Option")

            break

main()

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education