would someone be able to help me write this program? I am studying for a test tomorrow and this is one of the sample programs we have to know how to write. thank you.
The accepted wisdom is that paying only the minimum amount on a credit card balance can prolong payments for several months, if not years, and can cost the credit card holder large amounts in interest. You will write a program to verify this statement.
Your program will first ask the user for:
The balance on the credit card, a non-zero real amount
The annual interest rate, a non-zero real amount less than 100
The minimum payment, a non-zero amount, and a multiple of 10, e.g., $10, $20, or $ 30, but not $ 15 or $ 22
Validate all the above inputs.
Your program will then calculate:
The daily interest rate, which is the annual interest rate divided by 365 (for the number of days in the year) and 100 (to account for the percentage)
The number of months needed to pay off the balance - use a while loop to calculate this. Within the loop:
The total interest accrued at the end of each month, i.e., every 30 days. Use a for loop to calculate this (although it can be calculated without a loop, as described in your text book in problem 23.14). Note that the interest is compounded daily.
In order to compound interest daily, calculate interest for each day, and add it to the balance at the end of the day. Use the new balance to calculate interest for the next day. For example, if the balance is $ 100, and the daily interest rate is 0.1%, interest for the first day is 10 cents ($ 0.10). This is added to the balance and interest is calculated on $ 100.10 on the second day. The interest for the second day is $ 0.1001, which is added to the balance at the end of the day. On the third day, interest is calculated on $ 100.2001 and so on.
The new balance after adding the accrued interest and subtracting the minimum payment.
Note that the last payment may be less than the minimum payment. If you do not take this into account, the total payment will be incorrect.
Finally, the total interest paid by the user over the life of the loan. Use appropriate accumulator variable for this.
After each month, your program will print the new balance after adding accrued interest and subtracting the minimum payment.
At the end, your program will also print:
the total months needed to pay off the balance;
the total payments made;
the total interest paid on the original balance, which is the difference of total payments and the original balance.