Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

To calculate the monthly payment on a loan use the following formula: monthlyPmt

ID: 3582007 • Letter: T

Question

To calculate the monthly payment on a loan use the following formula: monthlyPmt = loan Amount * (mdir/(1 -(1 + mdir)^-nmp)); where mdir = monthly decimal interest rate = decimal APR/12 (IF APR is 12% (decimal APR = 0.12). then mdir = 0.12/12 = 0.01) nmp = number of monthly payments Example: If you borrow $100,000 for 30 years at 12% APR to buy a house, what is the monthly payment? monthlyPmt = 100000 *(0.01/(1 - (1 + .01)^-360)) => $1, 028.612596925504426479618534 Obviously, the bank does NOT want a check from you for $1, 028.612596925504426479618534 It wants your check to be made out for $1028.61, so the calculated amount needs to be rounded. Although printf("$%.2f", monthlyPmt); prints out $1028.61, the $1028.61 check you write is slightly less (1/4^th of a penny) than the exact, calculated, value needed each month, and over 360 months (30 years) the actual loan balance each month drops slower than the calculations predict. HOW can we internally round the calculated payment to the nearest penny, and keep our internal values correct, so that at 10, 15, 20, 30, etc., years out we know the correct loan balance? The correct way is to take the calculated value from the formula above and round it to the nearest penny. We can do this by taking the calculated dollar amount, and adding 1/2 cent, and then truncating to the nearest cent. $1028.6125969 + $0.005 => $1028.6175969 => $1028.61 Then we use this rounded value each month in our program. The easiest way to do this is to: multiply the calculated ($) payment by 100, converting it to pennies, then add 0.5 (1/2 penny), then convert it to an integer, throwing away everything to the right of the decimal point, then convert it back to a double and divide by 100, going back to dollars and cents. 1028.6125969 * 100.0 => 102861.25969 102861.25969 + 0.5 => 102861.75969 102861.75969 => 102861 102861 => 102861.00 102861.00/100.0 => 1028.61 Your task is to write a C program to read in a double value with 4-6 digits to the right of the decimal, then pass that value to a function you have written (double rounder(double value);] which returns the value rounded to the nearest penny. Your program then prints it out showing 6 digits to the right of the decimal. As in other programs, allow the user to repeatedly input values ("Want to try another value? (y/n)") Make the code legible, with a flowerbox, no one letter or global variables, etc. Neatness counts. Use the C pow (math.h) function to calculate (1 + mdir) to the -nmp power. In your calculations, be sure to use double precision floating point variables for full accuracy. That means scanf uses %If (lower case L and f) as the conversion specifier

Explanation / Answer

/*EMI Calculator (C program to calculate EMI).*/

#include <stdio.h>

#include <math.h>

int main()

{

    float principal, rate, time, emi;

    printf("Enter principal: ");

    scanf("%f",&principal);

    printf("Enter rate: ");

    scanf("%f",&rate);

    printf("Enter time in year: ");

    scanf("%f",&time);

    rate=rate/(12*100); /*one month interest*/

    time=time*12; /*one month period*/

    emi= (principal*rate*pow(1+rate,time))/(pow(1+rate,time)-1);

    printf("Monthly EMI is= %f ",emi);

     

    return 0;

}

/*EMI Calculator (C program to calculate EMI).*/

#include <stdio.h>

#include <math.h>

int main()

{

    float principal, rate, time, emi;

    printf("Enter principal: ");

    scanf("%f",&principal);

    printf("Enter rate: ");

    scanf("%f",&rate);

    printf("Enter time in year: ");

    scanf("%f",&time);

    rate=rate/(12*100); /*one month interest*/

    time=time*12; /*one month period*/

    emi= (principal*rate*pow(1+rate,time))/(pow(1+rate,time)-1);

    printf("Monthly EMI is= %f ",emi);

     

    return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote