Guest User

Untitled

a guest
Nov 25th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.     function calcMinExam() {
  3.         var first = document.minExam.first.value;
  4.         var second = document.minExam.second.value;
  5.         var ne = /^[0-9]+$/;
  6.         if(first.match(ne) && second.match(ne)) {
  7.             var minA = (8950/15) - (43/15)*first - (42/15)*second;
  8.             var minB = (7950/15) - (43/15)*first - (42/15)*second;
  9.             var minC = (7450/15) - (43/15)*first - (42/15)*second;
  10.             var minD = (6950/15) - (43/15)*first - (42/15)*second;
  11.             document.write("<h3> Results: </h3>");
  12.             document.write(minA+" to get an A<br />"+minB+" to get a B<br />"+minC+" to get a C<br />"+
  13.             minD+" to pass");
  14.             document.write("<p><a href=\"javascript:location.reload(true)\">Back</a></p>");
  15.         } else {
  16.             alert("Error: You must enter valid number grades.");
  17.         }
  18.     }
  19.     function calcFinalAvg() {
  20.         var first = document.finalAvg.first.value;
  21.         var second = document.finalAvg.second.value;
  22.         var exam = document.finalAvg.exam.value;
  23.         var ne = /^[0-9]+$/;
  24.         if(first.match(ne) && second.match(ne) && exam.match(ne)) {
  25.             var semAvg = Math.round(.43*first + .42*second + .15*exam);
  26.             document.write("<h3> Results: </h3>");
  27.             document.write("Semester Average: "+semAvg);
  28.             document.write("<p><a href=\"javascript:location.reload(true)\">Back</a></p>");
  29.         } else {
  30.             alert("Error: You must enter valid number grades.");
  31.         }
  32.     }
  33. </script>
Add Comment
Please, Sign In to add comment