BOT_Yokel

ICS3U1 Unit 1 Activity 3: Question 3

Jul 11th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This line makes the button, btnCalculate wait for a mouse click
  2. // When the button is clicked, the displayCoins function is called
  3. btnCalculate.addEventListener(MouseEvent.CLICK, displayCoins);
  4.  
  5. // This is the displayCoins function
  6. // e:MouseEvent is the click event experienced by the button
  7. // void indicates that the function does not return a value
  8. function displayCoins(e:MouseEvent):void
  9. {
  10.     // declare the constants
  11.     const INITIAL:Number = 69;
  12.  
  13.     // declare the variables
  14.     var Quarters:Number;
  15.     var Dimes:Number;
  16.     var Nickels:Number;
  17.     var Pennies:Number;
  18.     var Remainder1:Number;
  19.     var Remainder2:Number;
  20.     var Remainder3:Number;
  21.  
  22.     // calculate the debt burden per year
  23.     Remainder1 = INITIAL % 25
  24.     Quarters = (INITIAL - Remainder1) / 25
  25.     Remainder2 = Remainder1 % 10
  26.     Dimes = (Remainder1 - Remainder2) / 10
  27.     Remainder3 = Remainder2 % 5
  28.     Nickels = (Remainder2 - Remainder3) / 5
  29.     Pennies = Remainder3 / 1
  30.  
  31.     // put the values into the labels
  32.     lblQuarters.text = Quarters.toFixed(0);
  33.     lblDimes.text = Dimes.toFixed(0);
  34.     lblNickels.text = Nickels.toFixed(0);
  35.     lblPennies.text = Pennies.toFixed(0);
  36. }
Add Comment
Please, Sign In to add comment