jhylands

Economics game

Jan 20th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.74 KB | None | 0 0
  1. <html>
  2. <head>
  3. <style>
  4.  
  5. </style>
  6. <script>
  7. //Marcro economic variables
  8. var intrest = 0.5;
  9. var inflation = 3;
  10. var unemplyment = 5;
  11. function Run(){
  12.  
  13. if (inflation > 3){
  14. inflation = Math.round(10*((2* inflation)/intrest + Math.random()))/10;
  15. }
  16. else{
  17. inflation = Math.round(10*(4/intrest + Math.random()))/10;
  18. }
  19. unemployment = Math.round(10*( 2*intrest + Math.random()))/10;
  20. update();
  21. }
  22.  
  23. function update(){
  24.      var x = document.getElementById('intrestrates');
  25.      x.innerHTML = intrest + "%";
  26.      var y = document.getElementById('generalpricelevel');
  27.      y.innerHTML = inflation + "%";
  28.      if (inflation > 3 || inflation < 1){y.style.color = "red";}
  29.     else{y.style.color = "black";}
  30.     var z = document.getElementById('unemployment');
  31.     z.innerHTML = unemployment + "%";
  32.     if (unemployment > 5){z.style.color = "red";}
  33.      else{z.style.color = "black";}
  34. }
  35. function increaseintrest(){ intrest = intrest + 0.5; update(); }
  36. function decreaseintrest(){ if (intrest > 0 ){intrest = intrest - 0.5;} update(); }
  37. </script>
  38. </head>
  39. <body>
  40. <div style="position:absolute;top:10px;right:100px;">
  41. <input type="button" value="Next" onclick="Run();">
  42. </div>
  43. <center> <h1>Economics</h1></center>
  44. <p id="ab" ><b>Notes</b> - The macro economic  dependent variables; inflation, unemployment, <br />
  45.  - The macro economic independent variables; Intrest rates;</p>
  46.  
  47. <table id="eco" border="1" ><tr>
  48. <td><h3>Intrest rates</h3></td><td><h3>Inflation</h3></td><td><h3>Unemployment</h3></td></tr>
  49. <tr><td><x id="intrestrates">0.5%</x> <div style="text-align:right;" ><input type="button" value ="-" onclick="decreaseintrest();"><input type="button" value="+" onclick="increaseintrest();"></div></td><td id="generalpricelevel">3%</td><td><x id="unemployment" >5%</x></td></tr>
  50. </table>
  51. </body>
  52. </html>
Advertisement
Add Comment
Please, Sign In to add comment