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

Use a while loop . The loop stops when the balance is <=0. A partial sample outp

ID: 2997658 • Letter: U

Question

Use a while loop. The loop stops when the balance is <=0. A partial sample output is as follows:

                                                                                                                                          Your name

                                                                                                                                          Project 5 problem 1

Loan value = 10000

month   interest    balance

1              xxx.xx                   xxxxx.xx

2              xxx.xx                   xxxxx.xx

3              xxx.xx                   xxxxx.xx

Explanation / Answer

According to me this is more correct Formatted.

clc;
clear all;
amount=input('Enter Loan Amount');
interest_rate=input('Enter Monthly Interest Rate');
payment_month=input('Enter Monthly payment');
balance=amount;
month=0;
disp('Mr. Vikas Maheshwari');
fprintf('Amount is = %.2f',balance);
fprintf(' Month Interest Balance ');
while(balance>0)
    interest=(balance*interest_rate/100);
    balance=balance+interest;
    balance=balance-payment_month;
    month=month+1;
    fprintf('%d $%.2f $%.2f ',month,interest,balance);
end
disp('---------------------------------------------------------');
fprintf('Total Monthly Payments of $%.2f are %d Last month Payment is $%.2f ',payment_month,month-1,payment_month+balance);

Output:-

Enter Loan Amount10000
Enter Monthly Interest Rate0.75
Enter Monthly payment300
Mr. Vikas Maheshwari
Amount is = 10000.00

Month    Interest    Balance

1       $75.00   $9775.00
2       $73.31   $9548.31
3       $71.61   $9319.92
4       $69.90   $9089.82
5       $68.17   $8858.00
6       $66.43   $8624.43
7       $64.68   $8389.12
8       $62.92   $8152.03
9       $61.14   $7913.17
10       $59.35   $7672.52
11       $57.54   $7430.07
12       $55.73   $7185.79
13       $53.89   $6939.69
14       $52.05   $6691.73
15       $50.19   $6441.92
16       $48.31   $6190.24
17       $46.43   $5936.66
18       $44.52   $5681.19
19       $42.61   $5423.80
20       $40.68   $5164.48
21       $38.73   $4903.21
22       $36.77   $4639.98
23       $34.80   $4374.78
24       $32.81   $4107.59
25       $30.81   $3838.40
26       $28.79   $3567.19
27       $26.75   $3293.94
28       $24.70   $3018.65
29       $22.64   $2741.29
30       $20.56   $2461.85
31       $18.46   $2180.31
32       $16.35   $1896.66
33       $14.22   $1610.89
34       $12.08   $1322.97
35       $9.92   $1032.89
36       $7.75   $740.64
37       $5.55   $446.19
38       $3.35   $149.54
39       $1.12   $-149.34
---------------------------------------------------------
Total Monthly Payments of $300.00 are 38
Last month Payment is $150.66
>>