Write a program that do the following unit conversion based on user menu selection in python: (use while loop until the user enter ‘99’ selection to Quit) 1. Calculate Interest Rate 2. Calculate Mortgage 99 Quit If the user selects 1, then calculate interest rate. Create a python function that will continuously ask the user for inputs to calculate interest earned until the user enters a number 0 (zero) in principle. Once the user enters any number less than or equal to 0 in principle, the program will exit. The program should use while loop to ask the user for inputs. Assume the following variables: p is the initial principle balance r is the annual interest rate n is the amount of times the interest compounds in a year t is the number of years To calculate balance the formula used should be: total = p*(1+float(r/100)/n)**(n*t) interest = total - p Use import to include this function in the main program. If user choice selection 2, then calculate mortgage. For this, you need to write another separate python program function that will calculate mortgage payment that will be imported in. You can modify the interest program with the following formulate: The formula to calculate mortgage payment should be: monthlyRate = (interestRate / 100) / 12 numPayments = loanTerm * 12 monthlyPayment = loanAmount * monthlyRate \ * pow((1 + monthlyRate), numPayments) \ / (pow((1 + monthlyRate),numPayments) - 1) totalPayment = monthlyPayment * (loanTerm * 12) interestPaid = totalPayment - loanAmount If the user enters a number in the main menu that is not a valid menu selection, the program should ask the user to select one of the command numbers above. After finishing calculating something, the program should be able to calculate another set of numbers for the same task unless the user enters 0, where the program will then exit to the main menu. The program should look as it does in the images
Write a program that do the following unit conversion based on user menu selection in python: (use while loop until the user enter ‘99’ selection to Quit)
1. Calculate Interest Rate
2. Calculate Mortgage
99 Quit
If the user selects 1, then calculate interest rate. Create a python function that will continuously ask the user for inputs to calculate interest earned until the user enters a number 0 (zero) in principle. Once the user enters any number less than or equal to 0 in principle, the program will exit. The program should use while loop to ask the user for inputs.
Assume the following variables:
- p is the initial principle balance
- r is the annual interest rate
- n is the amount of times the interest compounds in a year
- t is the number of years
To calculate balance the formula used should be:
- total = p*(1+float(r/100)/n)**(n*t)
- interest = total - p
Use import to include this function in the main program.
If user choice selection 2, then calculate mortgage. For this, you need to write another separate python program function that will calculate mortgage payment that will be imported in. You can modify the interest program with the following formulate:
The formula to calculate mortgage payment should be:
monthlyRate = (interestRate / 100) / 12
numPayments = loanTerm * 12
monthlyPayment = loanAmount * monthlyRate \
* pow((1 + monthlyRate), numPayments) \
/ (pow((1 + monthlyRate),numPayments) - 1)
totalPayment = monthlyPayment * (loanTerm * 12)
interestPaid = totalPayment - loanAmount
If the user enters a number in the main menu that is not a valid menu selection, the program should ask the user to select one of the command numbers above.
After finishing calculating something, the program should be able to calculate another set of numbers for the same task unless the user enters 0, where the program will then exit to the main menu.
The program should look as it does in the images.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images