Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month.

The following variables contain values as described below:

balance - the outstanding balance on the credit card

annualInterestRate - annual interest rate as a decimal

monthlyPaymentRate - minimum monthly payment rate as a decimal

For each month, calculate statements on the monthly payment and remaining balance, and print to screen something of the format:

Month: 1
Minimum monthly payment: 96.0
Remaining balance: 4784.0
Be sure to print out no more than two decimal digits of accuracy - so print

Remaining balance: 813.41
instead of

Remaining balance: 813.4141998135
Finally, print out the total amount paid that year and the remaining balance at the end of the year in the format:

Total paid: 96.0
Remaining balance: 4784.0
A summary of the required math is found below:

Monthly interest rate= (Annual interest rate) / 12.0
Minimum monthly payment = (Minimum monthly payment rate) x (Previous balance)
Monthly unpaid balance = (Previous balance) - (Minimum monthly payment)
Updated balance each month = (Monthly unpaid balance) + (Monthly interest rate x Monthly unpaid balance)

Note that the grading script looks for the order in which each value is printed out. We provide sample test cases below; we suggest you develop your code on your own machine, and make sure your code passes the sample test cases, before you paste it into the box below.

Test Cases to Test Your Code With. Be sure to test these on your own machine - and that you get the same output! - before running your code on this webpage!
Click to See Problem 1 Test Cases

The code you paste into the following box should not specify the values for the variables balance, annualInterestRate, or monthlyPaymentRate - our test code will define those values before testing your submission.

Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month. Use raw_input() to ask for the following three floating point numbers: 1. the outstanding balance on the credit card 2. annual interest rate 3. minimum monthly payment rate For each month, print the minimum monthly payment, remaining balance, principle paid in the format shown in the test cases below. All numbers should be rounded to the nearest penny. Finally, print the result, which should include the total amount paid that year and the remaining balance.

Use the following equations.
Minimum monthly payment = Minimum monthly payment rate x Balance
(Minimum monthly payment gets split into interest paid and principal paid)
Interest Paid = Annual interest rate / 12 months x Balance
Principal paid = Minimum monthly payment – Interest paid
Remaining balance = Balance – Principal paid
Input Format

Enter the outstanding balance on your credit card: 4800

Enter the annual credit card interest rate as a decimal: .2

Enter the minimum monthly payment rate as a decimal: .02

Output Format

Month: 1

Minimum monthly payment: $96.0

Principle paid: $16.0

Remaining balance: $4784.0

Month: 2

Minimum monthly payment: $95.68

Principle paid: $15.95

Remaining balance: $4768.05

Month: 3

Minimum monthly payment: $95.36

Principle paid: $15.89

Remaining balance: $4752.16

Month: 4

Minimum monthly payment: $95.04

Principle paid: $15.84

Remaining balance: $4736.32

Month: 5

Minimum monthly payment: $94.73

Principle paid: $15.79

Remaining balance: $4720.53

Month: 6

Minimum monthly payment: $94.41

Principle paid: $15.73 Remaining balance: $4704.8

Month: 7

Minimum monthly payment: $94.1

Principle paid: $15.69

Remaining balance: $4689.11

Month: 8

Minimum monthly payment: $93.78

Principle paid: $15.63

Remaining balance: $4673.48

Month: 9

Minimum monthly payment: $93.47

Principle paid: $15.58

Remaining balance: $4657.9

Month: 10

Minimum monthly payment: $93.16

Principle paid: $15.53

Remaining balance: $4642.37

Month: 11

Minimum monthly payment: $92.85

Principle paid: $15.48

Remaining balance: $4626.89

Month: 12

Minimum monthly payment: $92.54

Principle paid: $15.43

Remaining balance: $4611.46

RESULT

Total amount paid: $1131.12

Remaining balance: $4611.46

Exam Question

Here is a step-by-step solution to the problem:

1. Initialize the variables:

previous_balance = balance
monthly_interest_rate = annualInterestRate / 12.0
total_paid = 0

2. Iterate over 12 months:

for month in range(1, 13):

3. Calculate the minimum monthly payment:

minimum_payment = monthlyPaymentRate * previous_balance

4. Update the total paid:

total_paid += minimum_payment

5. Calculate the monthly unpaid balance:

monthly_unpaid_balance = previous_balance - minimum_payment

6. Calculate the updated balance:

updated_balance = monthly_unpaid_balance + (monthly_interest_rate * monthly_unpaid_balance)

7. Print the statements:

print("Month:", month)
print("Minimum monthly payment:", round(minimum_payment, 2))
print("Remaining balance:", round(updated_balance, 2))

8. Update the previous balance for the next iteration:

previous_balance = updated_balance

9. Print the total paid and the remaining balance at the end of the year:

print("Total paid:", round(total_paid, 2))
print("Remaining balance:", round(updated_balance, 2))

Note: The round() function is used to round the decimal values to two decimal places, as specified in the problem statement.

To write a program that calculates the credit card balance after one year, you can follow these steps:

1. Define the variables: `balance`, `annualInterestRate`, `monthlyPaymentRate`.
2. Initialize two additional variables: `totalPaid` and `remainingBalance` to keep track of the total amount paid and the remaining balance.
3. Calculate the monthly interest rate: `monthlyInterestRate = annualInterestRate / 12`.
4. Loop through 12 months:
- Calculate the minimum monthly payment: `minimumPayment = monthlyPaymentRate * balance`.
- Calculate the monthly unpaid balance: `unpaidBalance = balance - minimumPayment`.
- Update the balance with interest: `balance = unpaidBalance + (monthlyInterestRate * unpaidBalance)`.
- Update `totalPaid` by adding `minimumPayment`.
- Print the current month, minimum monthly payment, and remaining balance.
5. After the loop ends, print the total amount paid and the remaining balance.

Here's an example implementation in Python:

```python
balance = 5000
annualInterestRate = 0.18
monthlyPaymentRate = 0.02

totalPaid = 0
remainingBalance = balance

monthlyInterestRate = annualInterestRate / 12

for month in range(1, 13):
minimumPayment = monthlyPaymentRate * remainingBalance
unpaidBalance = remainingBalance - minimumPayment
remainingBalance = unpaidBalance + (monthlyInterestRate * unpaidBalance)
totalPaid += minimumPayment

# Print the monthly payment and remaining balance for each month
print("Month:", month)
print("Minimum monthly payment:", round(minimumPayment, 2))
print("Remaining balance:", round(remainingBalance, 2))

# Print the total amount paid and the remaining balance after 1 year
print("Total paid:", round(totalPaid, 2))
print("Remaining balance:", round(remainingBalance, 2))
```

Make sure to replace the initial values of `balance`, `annualInterestRate`, and `monthlyPaymentRate` with the desired values for your test case.