It must prompt the user to enter, and accept their input, for the amount of the
ID: 3850997 • Letter: I
Question
It must prompt the user to enter, and accept their input, for the amount of the loan, the interest rate, and the
monthly payment.
• For the first three years of the loan repayment, for each month of the year: calculate the interest, apply the
payment, and calculate the remaining balance still owed on the loan. As these calculations are done each month,
add up the total interest paid and the total principal paid for the year. Note: The interest rate entered by
the user is the annual interest rate. Interest is compounded monthly.
• For each year, display a table with each month’s interest and principal payments, and the load balance after
that month’s payment is made. At the end of the year, display the total interest and total principal paid that
year, in the format shown below.
• The user may enter numbers with or without a fractional part.
• You may ignore any issues relating to financial transactions being rounded to a whole cent and simply store
the amounts as floating point numbers. However, when displaying numbers that represent amounts of money,
they must be displayed with two decimal places.
• The columns of numbers must be right-aligned as shown in the sample run, including the total interest and
principal for the year being aligned the columns that they’re totals of.
• A sample run of your program should look like:
Enter amount of loan: 30000
Enter interest rate: 5.5
Enter monthly payment: 345.60
YEAR 1
Month Interest Principal Balance
----- -------- --------- --------
1 137.50 208.10 29791.90
2 136.55 209.05 29582.85
3 135.59 210.01 29372.83
4 134.63 210.97 29161.86
5 133.66 211.94 28949.92
6 132.69 212.91 28737.01
7 131.71 213.89 28523.12
8 130.73 214.87 28308.25
9 129.75 215.85 28092.39
10 128.76 216.84 27875.55
11 127.76 217.84 27657.71
12 126.76 218.84 27438.88
-------- ---------
Year totals: 1586.08 2561.12
YEAR 2
Month Interest Principal Balance
----- -------- --------- --------
1 125.76 219.84 27219.04
2 124.75 220.85 26998.19
3 123.74 221.86 26776.34
4 122.72 222.88 26553.46
5 121.70 223.90 26329.56
6 120.68 224.92 26104.64
7 119.65 225.95 25878.69
8 118.61 226.99 25651.70
9 117.57 228.03 25423.67
10 116.53 229.07 25194.59
11 115.48 230.12 24964.47
12 114.42 231.18 24733.29
-------- ---------
Year totals: 1441.61 2705.59
YEAR 3
Month Interest Principal Balance
----- -------- --------- --------
1 113.36 232.24 24501.05
2 112.30 233.30 24267.75
3 111.23 234.37 24033.37
4 110.15 235.45 23797.93
5 109.07 236.53 23561.40
6 107.99 237.61 23323.79
7 106.90 238.70 23085.09
8 105.81 239.79 22845.30
9 104.71 240.89 22604.40
10 103.60 242.00 22362.41
11 102.49 243.11 22119.30
12 101.38 244.22 21875.08
-------- ---------
Year totals: 1288.99 2858.21
just a beginners course need help
Explanation / Answer
#include<stdio.h>
int main() {
double loan,rate,repayment,interest,principal,totalInterest,totalPrincipal ; //declarations
int i, year; //declarations
//user Inputs
printf("Enter loan amount: ");
scanf("%lf", &loan);
printf("Enter yearly rate: ");
scanf("%lf", &rate);
printf("Enter monthly repayment: ");
scanf("%lf", &repayment);
for (year = 1; year <= 3; year++) { //loop number of years
totalInterest = totalPrincipal = 0; //reset values
printf("YEAR %d Month Interest Principal Balance ",year);
for (i = 1; i<=12; i++) { //for each month calculate and print
interest = loan*rate/100/12;
principal = repayment - interest;
loan -= principal;
totalInterest += interest;
totalPrincipal += principal;
printf("%d %.2lf %.2lf %.2lf ",i,interest,principal,loan);
}
printf ("Year totals: %.2lf %.2lf ",totalInterest, totalPrincipal);
}
}
Here yoou go champ. Hope you like it. If you have any doubt, please feel free to comment below. I shall be glad to help you.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.