Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello all, I need help obtaining the output below for a loan interest program. My current code includes an extra monthly payment, but I need

Hello all, I need help obtaining the output below for a loan interest program. My current code includes an extra monthly payment, but I need to produce an output with only one extra payment made per year in December, the example uses 3000. My code and output (green console) are below as well. Please use C language, and thank you for any help!

image text in transcribed

#include #include #define Extra 200 void output_short_format(double loan_amount, double interest_rate, double term_year); void output_amortized(double loan_amount, double interest_rate, double term_year); double INTEREST=0; double PRINCIPAL=0; int main(void) { double principle, toprinciple, principal; double annual_rate; double monthly_rate; double interest_accrued; double payment = 1; double month = 1; double year, n; int choice;

printf("-------------------------------------------------------------------------------- "); printf(" LOAN TERMS "); printf("-------------------------------------------------------------------------------- "); printf(" "); printf(" ");

printf(" Enter the principle amount of the loan: "); scanf("%lf", &principle); printf(" Enter the annual interest rate: "); scanf("%lf", &annual_rate); printf(" Enter the loan term in years and press ENTER "); scanf("%lf", &year); output_short_format(principle,annual_rate,year); output_amortized(principle,annual_rate,year); return 0; } void output_short_format(double loan_amount, double interest_rate, double term_year) { double monthly_rate = interest_rate/ 1200; double payment = (loan_amount*interest_rate / 12 / 100 * (pow(1 + interest_rate / 12 / 100, term_year * 12) / (pow(1 + interest_rate / 12 / 100, term_year * 12) - 1))) ; payment = floor(payment*100.0) / 100.0; double total_interest; int n=0; while (n

printf("Loan Amount: %.f ",loan_amount); printf(" Interest rate: %.2f%% ",interest_rate); printf(" Term: %.f years ",term_year); printf("-------------------------------------------------------------------------------- "); printf(" Monthly payment is: %.2f ",payment); printf(" Total Interest is: %.2f ",(payment*term_year*12)-loan_amount+.34); printf(" Total amount paid is: %.2f ",payment*term_year*12+.34); } void output_amortized(double loan_amount, double interest_rate, double term_year) { double n; double principal; double interest_accrued; double toprinciple; int month=1; int year=1; double payment = 1; printf(" "); printf(" "); double monthly_rate = interest_rate / 1200; payment = (loan_amount*interest_rate / 12 / 100 * (pow(1 + interest_rate / 12 / 100, term_year * 12) / (pow(1 + interest_rate / 12 / 100, term_year * 12) - 1))) ; payment = floor(payment*100.0) / 100.0; n = (term_year * 12) - 3;

while (loan_amount > 0) { if((month-1)%12==0) { printf(" "); printf(" ------------------------------------------------------------------------------------------------------------------------ "); printf("Year\tMonth\tPrinciple\tInterest\tTo principle\t Principle Bal. | INTEREST\tPRINCIPAL\tEXTRA "); printf(" ------------------------------------------------------------------------------------------------------------------------ %d",((month-1)/12)+1); } principal = loan_amount; interest_accrued = loan_amount * monthly_rate; loan_amount = loan_amount + interest_accrued - payment; toprinciple = payment - interest_accrued; INTEREST+=interest_accrued; PRINCIPAL+=(toprinciple+Extra); if (month>=1) { printf("\t%d\t%.0f\t\t%.0f\t\t%.0f\t\t%.0f\t | %.0f\t\t\t%.0f\t%d ", month, principal, interest_accrued, toprinciple, loan_amount,INTEREST,PRINCIPAL,Extra); } month++; if(month==1) printf("%d",year); } printf(" ------------------------------------------------------------------------- "); }

image text in transcribed

4-ExtraYearlyPayment Notepad File Edit Format View Help Year Month Interest Principal Balance INTEREST PRINCIPAL EXTRA 500 498 496 494 492 490 488 486 484 481 479 477 610 149390 I 612 148779 614 148165 616 147550 I 618 146932 620 146312 622 145690 I 624 145066 626 144440 628 143812 I 630 143182 I 632 139550 I 500 998 1494 1988 2480 2969 3457 3943 4426 4908 5387 5864 610 1221 1835 2450 3068 3688 4310 4934 5560 6188 6818 4. 7 8 9 10 12 10450 3000 Year Month Interest Principal Balance INTEREST PRINCIPAL EXTRA

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions

Question

Question What is a Roth 401(k) feature?

Answered: 1 week ago