Advice on a coding lesson! Credit Card debt and Loops

As my students were learning about loops, I really wanted to add  tie-in to personal financial literacy.  My students are still very new to programming and this was their first experience with “for” loops. I am struggling with the right amount of structure for this task and would love your help reflecting on it.

Relevant standards:

7th grade Expressions and Equations: Multi-step ratio and proportion problems

High School Functions: Exponential Growth

Computer Science Teachers Association: Middle School

I gave the students this problem situation.

Fresh out of college, you need to buy furniture for your new apartment. You’re able to get a credit card with a 15% Annual Percentage Rate (APR). You immediately charge $5000 to the credit card for your new accessories for the crib.

The minimum payment on the credit card is $25, which you pay faithfully every month.
The credit card company charges you 1/12 of the APR every month on whatever money is left on the card.

Write a program that will calculate how much you have left to pay after 36 months.

From here, I have choices.

1) I can give students the pseudocode, and have them write the code.

Use variables for:
amount of debt, 
monthly payment,
number of months,
Repeat this loop for the number of months:
 Subtract the monthly payment from the debt.
 Add the fee to the debt (1/12 of the APR * the debt)

At the end, show how much debt is left.

2) I can give them skeleton code to fill in.

var debt = 5000;
var apr = 0.15;
var payment = 25;
var months = 36;
// complete
println( );
for(var i = 0;i<months; i+=1)
 // add code and finish println statement
 println( );
// complete
println( );

3) I can have them enter the “canned” code and then modify it to answer the key questions.

var debt = 5000;
var apr = 0.15;
var payment = 25;
var months = 36;

println("In the beginning you owed: $" + debt);

 println("At the start of month " + i + " you have $" +debt + " in debt");
 debt = debt - payment;
 debt = debt + (apr / 12 * debt);

println("At the end you have $" + debt + " in debt.");

Here are the questions.
How much will you have to pay each month to pay off the credit card in 36 months?

Modify the program so it prints a message when the card is paid off.

Create and answer other questions with this simulation. Note your questions and what the answers are.

Since this was a new programming structure, I went with option 3. I loved the conversation I had with the students and the interesting questions they asked – but I have been wondering if I should have gone with less scaffolding so they could problem-solve themselves.  Always such a tough call when learning something new. What would you have done?


Tags: , , , , ,

About dupriestmath


Leave a Reply


You are commenting using your account. Log Out / Change )

Twitter picture


Facebook photo


Google+ photo


Connecting to %s

%d bloggers like this: