Advertisement
CodenameDuchess

Javascript

Oct 5th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5. <script>
  6.  
  7. function calcFunction(a1,a2,t1,t2) {
  8. var AVG = ( ( ( a2 / a1 ) *.3 + ( t2 / t1 ) *.7 ) * 100.0 );
  9. letterGrade( AVG );
  10. document.getElementById("percent").innerHTML = AVG;
  11. }
  12.  
  13. function letterGrade( x ){
  14.  
  15. var z = "Remember, this is not your current score and it can change based on future grades.";
  16.  
  17. if( avg >= 92.0) {
  18. var lg ="A";
  19. elem = document.getElementById("demo");
  20. elem.innerHTML = z;
  21. return lg;
  22.  
  23. }
  24.  
  25. else if ( avg < 92.0 && avg >= 84.0){
  26. var lg ="B";
  27. elem = document.getElementById("demo");
  28. elem.innerHTML = z;
  29. return lg;
  30.  
  31. }
  32.  
  33. else if ( avg < 84.00 && avg >= 76.00){
  34. var lg ="C";
  35. elem = document.getElementById("demo");
  36. elem.innerHTML = z;
  37. return lg;
  38.  
  39. }
  40.  
  41. else if ( avg < 76.00 && avg >= 68.00){
  42. var lg ="D";
  43. elem = document.getElementById("demo");
  44. elem.innerHTML = z;
  45. return lg;
  46.  
  47. }
  48.  
  49. else {
  50. var lg ="F";
  51. elem = document.getElementById("demo");
  52. elem.innerHTML = z;
  53. return lg;
  54.  
  55. }
  56. }
  57.  
  58. function resetFunction() {
  59. location.reload();
  60. }
  61.  
  62. </script>
  63. </head>
  64.  
  65. <h1>Grade Calculator</h1>
  66. <h2>Matthew Rowe 466-2</h2>
  67.  
  68.  
  69. <body>
  70. <p>Enter your Scores and calculate your percentage thus far: </p>
  71.  
  72. <table>
  73. <tr>
  74. <td>Total assignment points: <input type="text" name="assign1" id="assign1"></td>
  75.  
  76. <td>Your assignment points: <input type="text" name="assign2" id="assign2"></td>
  77. </tr>
  78. <tr>
  79. <td>Total test/quiz points: <input type ="number" name="test1" id="test1"></input></td>
  80. <td>Your test/quiz points: <input type ="number" name="test2" id="test2"></input></td>
  81. </tr>
  82. </table>
  83.  
  84. <form>
  85. <input type="button" onclick="calcFunction(assign1,assign2,test1,test2)" value="Calculate">
  86. <button type="button" onclick="resetFunction()">Reset</button>
  87.  
  88. </form>
  89. <tr>
  90. <td>Your percentage thus far: <input type ="number" name="percent" id="percent"></input></td>
  91. <td>Your Letter grade thus far: <input type ="text" name="letter" id="letter"></input></td>
  92. </tr>
  93.  
  94. <p id="demo"> </p>
  95.  
  96. </body>
  97. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement