0% found this document useful (0 votes)
26 views

ictLab8

Uploaded by

eshanaliprivate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

ictLab8

Uploaded by

eshanaliprivate
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

HOME TASK

Mary Smith, a student, has borrowed $3,000 to help pay her college expenses. After setting
up a budget, $85 was the maximum monthly payment she could afford to make on the loan.
Develop a solution to calculate and print the interest, the principal, and the balance on the
loan per month. Other information she would like to know is the number of years and
months it will take to pay the loan back and the total interest she will pay during that
period. The interest rate is 1% per month on the unpaid balance.
Keep in mind these formulas:
interest_normal = balance*interest_rate
payment = balance interest
new_balance = balance – payment

KEY POINTS:
1. Variable Declaration:
sum, balance, principal, interest, monthlyPayment, payment, interestRate, rotalInterestPaid,
monthCounter: These variables are declared to store various values used in the loan repayment
calculation.
2. Initialization:
balance: The initial loan balance is set to $3000.
monthlyPayment: The maximum monthly payment Mary can afford is set to $85.
interestRate: The interest rate per month is set to 1% (0.01).
monthcounter: Initialized to 0 to count the number of months.
3. Loop:
It enters a loop that continues until the loan balance (balance) becomes zero or less.
4. Loop Body:
Increment monthCounter by 1 to keep track of the number of months.
Calculate the interest for the current month using the formula interest = interestRate * balance.
Update totalInterestPaid by adding the interest calculated for the current month.
Calculate the total amount due (sum) for the current month by adding balance and interest.
Check if sum is less than or equal to monthlyPayment. If true, set payment to sum; otherwise,
set payment to monthlyPayment.
Calculate the principal payment for the current month as principal = payment - interest.
Update balance by subtracting the principal payment.
5. Output Inside Loop:
Display information about the current month, including interest, principal, and remaining
balance.
6. Output Outside Loop:
After the loop, display the total number of months (monthCounter), total years
(floor(monthCounter/12)), remaining months (monthCounter % 12), and total interest paid
(totalInterestPaid).
IMPLEMENTATION:
OUTPUT:
The output is not fully displayed. Only some part of it
and the final display screen outside the loop is shown
below because the loop runs for 44 times and the main
idea for computation remains the same for each
month.

CONCLUSION: In conclusion, this lab session


effectively utilized repetition structures to develop a
solution for Mary Smith's loan repayment scenario. By
accurately implementing the provided formulas and logic, the program calculated and displayed
the interest, principal, and remaining balance per month, along with additional information such
as the total duration of repayment and the total interest paid.

You might also like