225k views
0 votes
3. C++ Programming: Please use LOOP only, and also provide detailed comments for everything that is included in the code. Please look at both examples for this question to understand what to do. Thank you very much.

Question 3: (Please use LOOP only) The UBANK bank grants a loan only if the total amount of interest it can collect is greater than $30,000 and the term of the loan is less than or equal to 20 years. To answer to this strict policy, you must write a C++ program (use LOOP only) that takes as input the sum you want to borrow and the bank's annual interest rate. The program must then calculate the number of years necessary for the accumulated interest that the bank can collect exceeds $30,000. In case the number of years exceeds 20 years, the loan is denied.
The program must display the number of years required as well as the details of the accrued interest and the total amount the borrower will have to repay to the bank (see examples). It is clear that each year, the interest is calculated on the new amount. So for a loan of 120,000 dollars at 7%, we will have:
First year: interest=12000*0.07=8400
Second year interest=(128400)*0.07=8988
Second year interest=(137388)*0.07=9617.16
Etc
Example 1:
Enter the amount that you want to borrow: 120000
Enter the annual interest rate: 7
Year 1: annual interest = 8400.00: accrued interest = 8400.00, total amount to repay = 128400.00
Year 2: annual interest = 8988.00: accrued interest = 17388.00, total amount to repay = 137388.00
Year 3: annual interest = 9617.16: accrued interest = 27005.16, total amount to repay = 147005.16
Year 4: annual interest = 10290.36: accrued interest = 37295.52, total amount to repay = 157295.52
The loan is accepted. The interest accrued over 4 years will be 37295.52 dollars.
Example 2:
Enter the amount that you want to borrow: 30000Enter the annual interest rate: 2
Year 1: annual interest = 600.00: accrued interest = 600.00, total amount to repay = 30600.00
Year 2: annual interest = 612.00: accrued interest = 1212.00, total amount to repay = 31212.00
Year 3: annual interest = 624.24: accrued interest = 1836.24, total amount to repay = 31836.24
Year 4: annual interest = 636.72: accrued interest = 2472.96, total amount to repay = 32472.96
Year 5: annual interest = 649.46: accrued interest = 3122.42, total amount to repay = 33122.42
Year 6: annual interest = 662.45: accrued interest = 3784.87, total amount to repay = 33784.87
Year 7: annual interest = 675.70: accrued interest = 4460.57, total amount to repay = 34460.57
Year 8: annual interest = 689.21: accrued interest = 5149.78, total amount to repay = 35149.78
Year 9: annual interest = 703.00: accrued interest = 5852.78, total amount to repay = 35852.78
Year 10: annual interest = 717.06: accrued interest = 6569.83, total amount to repay = 36569.83
Year 11: annual interest = 731.40: accrued interest = 7301.23, total amount to repay = 37301.23
Year 12: annual interest = 746.02: accrued interest = 8047.25, total amount to repay = 38047.25
Year 13: annual interest = 760.95: accrued interest = 8808.20, total amount to repay = 38808.20
Year 14: annual interest = 776.16: accrued interest = 9584.36, total amount to repay = 39584.36
Year 15: annual interest = 791.69: accrued interest = 10376.05, total amount to repay = 40376.05
Year 16: annual interest = 807.52: accrued interest = 11183.57, total amount to repay = 41183.57
Year 17: annual interest = 823.67: accrued interest = 12007.24, total amount to repay = 42007.24
Year 18: annual interest = 840.14: accrued interest = 12847.39, total amount to repay = 42847.39Year 19: annual interest = 856.95: accrued interest = 13704.34, total amount to repay = 43704.34
Year 20: annual interest = 874.09: accrued interest = 14578.42, total amount to repay = 44578.42
Loan is denied. The interest rate accrued over 20 years is 14578.42 dollars

1 Answer

3 votes

Final answer:

The total amount of interest from a $5,000 loan after three years with a 6% simple interest rate is $900. If you receive $500 in simple interest from a $10,000 loan over five years, the interest rate charged is 1%. Compound interest can significantly affect the total accrued amount over time compared to simple interest.

Step-by-step explanation:

To calculate the total amount of interest from a $5,000 loan after three years with a simple interest rate of 6%, we can use the simple interest formula: Interest = Principal × Rate × Time. Here, Principal is $5,000, Rate is 6% per annum, and Time is 3 years.

Interest = $5,000 × 0.06 × 3 = $900.

Therefore, the total amount of interest on this loan after three years would be $900.

To determine the interest rate charged on a loan for $10,000 where you received $500 as simple interest over five years, we again use the simple interest formula, solving for Rate this time:

Interest = Principal × Rate × Time

$500 = $10,000 × Rate × 5

Rate = $500 / ($10,000 × 5)

Rate = 0.01 or 1%

The interest rate charged was 1% per annum.

It's worth noting that compound interest can have a significant impact on the amount accrued over time, especially with larger principals and longer terms, as it calculates interest on both the initial principal and the accumulated interest. Simple interest, on the other hand, only calculates interest based on the original principal amount.

User Buddhi Weerasinghe
by
7.6k points