Docstoc

Interest

Document Sample
Interest Powered By Docstoc
					Interest
           1
                                                                                                                                                                2




Contents
Overview ....................................................................................................................................................... 3
Graphics to develop ...................................................................................................................................... 3
  For level one.............................................................................................................................................. 3
Level One Application ................................................................................................................................... 3
Level Two Application ................................................................................................................................... 7
Level Three Application.................................................................................. Error! Bookmark not defined.
                                                                                                             3




Overview
Over the past year, in the United States much attention has been given to the effect that high mortgage
and credit card interest rates have on the average citizen. Some people have purchased houses using
“balloon” mortgages – mortgages that start with a low interest rate and then are adjusted to higher
rates. Others face credit card interest rates that increase in exploitative ways when credit card users to
not pay monthly balances on time. Since, interest can be compounded at a given rate of according to a
given schedule, consumers sometimes find that their debt increases in dramatic ways if they do not pay
on time.


Graphics to develop
Look in the resource folder for starter files.


For level one
The dollar wheel, button(s).

For level two
Same as for level one.

For level three
Same as for level one and two.

Level One Application
In this application you will develop a way to calculate an amount of money saved when a certain
amount is in the bank. As well as calculated an amount owned after a loan is taken out.

Set Up
Create a new directory for the interest lab. Open a new .fla document and save it as “Interest1.” There
will only be one layer in the timeline.
Make a button and save in the library.

The Money Wheel
Earlier you have developed a cool animation (maybe similar to the one in the demo application). You will
use it later in the lab, so make sure it is saved in the library. You can use the one in the resource folder if
you would like.




The Display
                                                                                                            4



We will work only in the first frame of the timeline. In a static text box, using nice big font (40 pts) write
the title: Calculate Loans!! Underneath, also in a static text box, place the description of the functionality
of the application:
“If you put in money to a savings account, how much would you get in 5 years? Enter the amount of
money you'd put in on the left, then click Save! Then see how much you'll have in 5 years!”

Next, create six static text boxes, two input text box and one dynamic text box (with starting values as
seen below). Enter the text and name the instances as follows:




In the paragraph section of the properties tab set the behavior in the drop down menu as “single line.”

To the right of the Input text box place an instance of the button and call it “CalculateSavings.” Over the
button put a static text box that reads “Borrow!”
To the right of that place and instance of the money wheel (is the graphics that you have developed)
and call it “dollarWheel.”

Save and run the application. Everything should appear on the stage without any functionally attached
to it yet.

The Code
                                                                                                            5



Now we can insert the code to perform the calculations. The variables are defined right in the code.
Refer to the Opportunity Worksheet done earlier in the day for the samples of code in regard to the
equation.
Place the following code in the actions frame to perform the calculations and animate the money
wheel.

stop();

var n:int;
var Y:int;
var APR:Number;

CalculateSavings.addEventListener(MouseEvent.CLICK, Savings);

function Savings(event:MouseEvent):void {
        var Money:Number=Number(toBeSaved.text);
        var Savings:Number=CalcSavings(Money);
        moneySaved.text=Savings.toFixed(2).toString();
        dollarWheel.gotoAndPlay(2);
}

function CalcSavings(P:Number):Number {
        n=360;
        Y=5;
        APR=Number(interest.text)/100;
        var A:Number= P*(Math.pow(1+APR/n,n*Y));
        return (A);
}
Save and run the application. Sweet, lets save some money!


Level Two Application
It can be difficult to set aside one large lump sum of money for the future. What often happens is one
sets aside a certain amount of money every week or month for a specific period of time. In this
application, you will develop a calculation for saving an amount with a given interest rate for a certain
amount of years.

Set Up

Save the first version as “Interest2.fla” in the same directory.
First, replace the description text with the new one:
                                                                                                          6



“If you put in money to a savings account every month, how much would you get in a few years? Enter
the amount of money you can put in every month, and the interest rate on the account. Then set the
amount of years and click Save! Then you can see how much you'll have, as well as how much additional
money the bank will give you.

-Tip- See how much you need to save for college!”

In order to introduce a new variable into the calculation – that being the number of years – we need to
make some additions to the stage:




The Code
                                                                                                            7



Make the following additions to the code.

Add this line in the Savings function:
calcEarned(Money,Savings);
It will call the calcEarned function (added below) to calculated the money earned from the interest.

The calcSavings function will need to have the following changes:

function CalcSavings(PMT:Number):Number {
        n=12;
        Y=Number(years.text);
        APR=Number(interest.text)/100;
        var A:Number= PMT*((Math.pow(1+APR/n,n*Y)-1)/(APR/n));
        return (A);
}

Finally, add the function that will calculate the money earned from the interest:

function calcEarned(Money:Number, Savings:Number):void{
        var Earned:Number=(Savings-n*Y*Money)
        interestEarned.text=Earned.toFixed(2).toString();
}


Save and run the completed application. Sweet, let’s save some money.


Level Three Application

Set Up
Save the previous version as a different .fla file with the name “Interest3.”

The Display
First, right click on the second frame in the timeline and insert a blank key frame. The first frame will
remain mostly the same, except for an addition, described below.
In the second frame, however, create the same set up as in the first frame with the changes in the title,
description text and the names of the instances as seen below.

The description text should now read:

“Say you want to take out a loan to buy something big. You can get a loan with a reasonable interest
rate, that you pay off a little bit every month. Enter how big of a loan you'd like, then click Borrow! Then
                                                                                                       8



see how much you'd have to pay every month. Then see how much you'll end up paying the bank in the
end-Try comparing this to the initial amount you borrowed!

-Tip- It's already set up for a typical house loan.”

The sage of the second frame should look like this:




Pull in an instance of the button on the stage and call it “CalculateOwed;” over place a static text box
that reads “Borrow!” In addition, pull an instance of the money wheel animation on the stage, make the
instance name “dollarWheel2.”
You can use the same button for the following task or create a new one.
In the first frame make the following addition to the bottom right hand corner of the stage. Here, the
button has instance name of “toOwed”
                                                                                                         9




Likewise, in the second frame make similar additions. Here, the instance of the button is “toSaved.”




The Code
Before writing the code for the loan calculations, we need to insert code that would allow the user to
switch between the two frames.

Add the following code in the first frame of the actions screen:

toOwed.addEventListener(MouseEvent.CLICK,nextPage);

function nextPage(event:MouseEvent):void {
        this.nextFrame();
}




And this code in the second frame:
stop();

toSaved.addEventListener(MouseEvent.CLICK,prevPage);

function prevPage(event:MouseEvent):void {
        this.prevFrame();
}

Save and run the application. At this point the user should be able to perform all the calculations on the
first screen as developed in application two, but in addition be able to switch between the two frames.

Now we can add the code that will perform all the calculating functions for the loans that you have
developed in the MOW. Note how the savings plan formula is coded differently than the compound
formula in the previous application.

Add the following code to frame two:

var n:int;
var Y:int;
                                                                                                   10



var APR:Number;

CalculateSavings.addEventListener(MouseEvent.CLICK, Savings);

function Savings(event:MouseEvent):void {
        var Money:Number=Number(toBeSaved.text);
        var Savings:Number=CalcSavings(Money);
        moneySaved.text=Savings.toFixed(2).toString();
        calcEarned(Money,Savings);
        dollarWheel.gotoAndPlay(2);
}

function CalcSavings(PMT:Number):Number {
        n=12;
        Y=Number(years.text);
        APR=Number(interest.text)/100;
        var A:Number= PMT*((Math.pow(1+APR/n,n*Y)-1)/(APR/n));
        return (A);
}

function calcEarned(Money:Number, Savings:Number):void{
        var Earned:Number=(Savings-n*Y*Money)
        interestEarned.text=Earned.toFixed(2).toString();
}

Save and run the application. This complete application should accurately calculate the numbers…so you
can start making some plans for the future…

				
DOCUMENT INFO