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
Solve multi-step real-life and mathematical problems posed with positive and negative rational numbers in any form (whole numbers, fractions, and decimals), using tools strategically. Apply properties of operations to calculate with numbers in any form; convert between forms as appropriate; and assess the reasonableness of answers using mental computation and estimation strategies.

High School Functions: Exponential Growth
Observe using graphs and tables that a quantity increasing exponentially eventually exceeds a quantity increasing linearly, quadratically, or (more generally) as a polynomial function.

Computer Science Teachers Association: Middle School
Implement problem solutions using a programming language, including: looping behavior, conditional statements, logic, expressions, variables, and functions.

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);

for(var i = 0;i<months; i+=1)
 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

I'm a former software engineer who has taught middle school math and computer science for the past 6 years. I believe every kid has the right to be a thinker. I started this blog to save resources for integrating programming in the Common Core math classroom. I also use it to save my lessons and reflections from teaching budding computer scientists! Coding has transformed how I teach and think. You'll love what it does for you. You should try it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: