Write a program that calculates a monthly mortgage payment; we will assume that
ID: 3572393 • Letter: W
Question
Write a program that calculates a monthly mortgage payment; we will assume that the interest rate is compounded monthly. You will need to do the following: Prompt the user for a double representing the annual interest rate. Prompt the user for the number of years the mortgage will be held (typical input here is 10, 15, or 30). Prompt the user for a number representing the mortgage amount borrowed from the bank.
Output a summary of the mortgage problem, as follows: The annual interest rate in percent notation The mortgage amount in dollars The monthly payment in dollars, with only two significant digits after the decimal point The total payment over the years, with only two significant digits after the decimal point The overpayment, i.e., the difference between the total payment over the years and the mortgage amount, with only two significant digits after the decimal point The overpayment as a percentage (in percent notation) of the mortgage amount
Use these Calculate the monthly payment using the following formulas: Monthly payment = (mIR * M) / (1 – (1 / (1 + mIR)(12*nOY) )), Where: mIR = monthly interest rate = annual interest rate / 12 nOY = number of years M = mortgage amount
Use these Calculate the monthly payment using the following formulas: Monthly payment = (mIR * M) / (1 – (1 / (1 + mIR)(12*nOY) )), Where: mIR = monthly interest rate = annual interest rate / 12 nOY = number of years M = mortgage amount
Explanation / Answer
#include <stdio.h>
int main(){
double apr, mortage_amount, total_amount, monthly_amount;
int no_of_years;
printf("Enter the Annual Interest rate : ");
scanf("%lf", &apr);
printf("Enter the no of years of Mortage holding : ");
scanf("%d", &no_of_years);
printf("Enter the Mortage amount : ");
scanf("%lf", &mortage_amount);
double mIR = apr/12;
monthly_amount = (mIR * mortage_amount)/ (1-(1/(1+mIR)*(12*no_of_years)));
total_amount = 12 * no_of_years * monthly_amount;
printf("APR(%%) Mortage amount Monthly Payment Total Payment Overpayment ");
printf("%.2lf %.2lf %.2lf %.2lf %.2lf ", apr, mortage_amount,monthly_amount, total_amount, total_amount-mortage_amount);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.