Hi there everybody
I’m working on a little project where I have to simulate a credit card statement and show how making minimum payments for 6 months doesn’t lower your balance very quickly. They can scroll through a bunch of items to pretend ‘purchase’. When they’re done shopping, the code is supposed to calculate the interest being charged, and the minimum payment due, until the balance is gone or six months have passed… which ever comes first. If they only spent $20.00, they’ll pay it off before 6 months is up. If they spend a ton of money, then at the end of 6 months they’ll have a statement that has not decreased significantly.
My calculations aren’t working. It’s boggling my brain. I’ve been testing it with $100 as the total for all purchases. Rather than a nested function, maybe I should be using a for loop to count through the 6 months.
I’ve pasted in sample code with a static $100 as the purchases. I’ll attach a file too.
Any help would be absolutely fabulous.
//initial values for variables and symbols.
statementNumber=1;
mindue_rate=0.025;
PRFC=0.049827;
_root.allPurchases=100.00
//initial calculation for first month (because there is no interest on the first month).
month1=_root.allPurchases;
month1_mindue=month1*mindue_rate;
if(month1<10.00){
tipBox2.tipBoxText.text="Your total purchases were $"+_root.allPurchases+". Your balance is less than $10.00. That means you pay the total amount charged to your credit card on this bill. You have no balance to carry forward to month two. If you want to find out how interest can accumulate, do some more shopping and click again to view this statment. To learn more about this statement, roll your mouse over the terms.";
tipBox2.pointerRight._visible=0;
tipBox2.pointerLeft._visible=0;
//statementStatus._visible=100;
//statementStatus.definition_txt.text="Your balance is less than $10.00. That means you pay the total amount charged to your credit card on this bill. You have no balance to carry forward to month two. If you want to find out how interest can accumulate, do some more shopping and click again to view this statment.";
new_balance_total.text=month1
amount=month1;
}else if((month1>9.99)&&(month1_mindue<10.00)){
//statementStatus._visible=100;
//statementStatus.definition_txt.text="You pay 10.00 bucks";
month1_mindue=10.00;
PRFC_calc=(month1-month1_mindue)*PRFC;
month1_carryForward=(month1-month1_mindue)+PRFC_calc;
amount=int(month1_carryForward*100)/100;
calcAmounts();
}else {
month1_mindue_round=int(month1_mindue*100)/100;
trace("You pay the mindue "+month1_mindue_round);
PRFC_calc=(month1-month1_mindue)*PRFC;
month1_carryForward=(month1-month1_mindue)+PRFC_calc;
amount=int(month1_carryForward*100)/100;
calcAmounts()
}
function calcAmounts(){
statementNumber+=1;
if (amount<10.00){
//they can't carry a balance for 6 months (and pay only the min due) because they didn't purchase enough items. statementSaus informs them of this and what month they carried a balance to(from 2-6)
//statementStatus._visible=100;
//statementStatus.definition_txt.text="Your balance is less than $10.00. That means you pay the total amount charged to your credit card on this bill. You have no balance to carry forward to month two. If you want to find out how interest can accumulate, do some more shopping and click again to view this statment.";
tipBox2.tipBoxText.text="Your total purchases were $"+_root.allPurchases+". Your current balance is less than $10.00. That means you pay the total amount charged to your credit card on this bill. You have no balance to carry forward to month 2. If you want to find out how interest can accumulate, do some more shopping and click again to view this statment. To learn more about this statment, roll your mouse over the terms.";
tipBox2.pointerRight._visible=0;
tipBox2.pointerLeft._visible=0;
}
else if((amount>10.00)&&(mindue<10.00)){
amountMindue=10.00;
trace("You pay 10.00 bucks for statment number "+statementNumber);
PRFC_calc=(amount-amountMindue)*PRFC;
amount_carryForward=(amount-amountMindue)+PRFC_calc;
amount=int(amount_carryForward*100)/100
calcAmounts();
}
else {
amountMindue=amount*0.025;
trace("this is the calculation for month"+statementNumber+" and the decreasing minimum due is "+amountMindue);
PRFC_calc=(amount-amountMindue)*PRFC;
amount_carryForward=(amount-amountMindue)+PRFC_calc;
amount=int(amount_carryForward*100)/100;
if(statementNumber<7){
calcAmounts();
}else {
new_balance_total.text=amount;
//statementStatus._visible=100;
//statementStatus.definition_txt.text="This is what your statment looks like after paying only the minimum balance for 6 months. The periodic interest rate (4.9287%) is twice that of your minimum payment due (2.5% of your balance), makes it difficult to reduce your balance. "+ month1;
tipBox2.tipBoxText.text="Your total purchases were $"+_root.allPurchases+". This is what your statment looks like after paying only the minimum balance for 6 months. The periodic interest rate (4.9287%) is twice that of your minimum payment due (2.5% of your balance), makes it difficult to reduce your balance. To learn more about this statement, roll your mouse over the terms.";
}
}
}