Loading...
Logo
Processing Forum

Credit Card Interest

in General Discussion  •  Other  •  1 year ago  
Need help I have to write a function that computes the total interest charged on a credit card before it is paid off and list all the inputs the function will need, i don't know where to start and please do not reply in code so i can figure it out myself

Replies(2)

OK, I first thought it was spam, with such subject...
I appreciate the last sentence. But I moved the topic, as I consider Programming Questions to be about code you already wrote. I move here such generic, open ended questions, PQ are more for questions about specific code.

I don't know much about finance, so I have no idea about this "total interest charged on a credit card before it is paid off". Do you have a formula? If not, perhaps you can do some Internet search? What inputs the function need? I suppose it can be an amount of money, an interest rate, a duration, such things...
Well, you would need to know the initial balance, the interest rate being charged each month and the amount being paid off each month, and you'd need a separate variable to store the total interest. Each iteration, subtract the payment from the balance. If the balance >0, work out the interest charged and add it to the balance and to the total interest charged. Rinse and repeat until the balance <=0, then return the total interest charged. 

Does that make sense?