Showing posts with label Subject Grade Solver in JavaScript. Show all posts
Showing posts with label Subject Grade Solver in JavaScript. Show all posts

Monday, November 16, 2015

Subject Grade Solver in JavaScript

A program that I wrote that will compute the prelim, midterm and endterm grade in a particular subject using JavaScript this program also give a remarks whether the subject is PASSED or FAILED.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.


Sample Program Output


Program Listing

<html>
<style>
body,p {

  font-family:arial;
  font-size:16px;
  font-weight:bolder;
 }

    .container {
        width: 350px;
        clear: both;
    }
    .container input {
        width: 100%;
        clear: both;
    }

    </style>
<div class="container">
<body>
<h3> Subject Grade Solver </h3>
<br/>Subject

<input type="text" id="subject" name="subject">
<br>
<br/> Prelim Grade
<input type="text" id="prelim" name="prelim">
<br>
<br/> Midterm Grade
<input type="text" id="midterm" name="midterm">
<br>
<br>Endterm Grade
<input type="text" id="endterm" name="endterm">
<br>
<br>
<button onclick="compute_grade()">Compute Grade</button>
<br><br>
<p id="demo"></p>
<p id="demo2"></p>
<p id="demo3"></p>
</div>
<script>
  function compute_grade() {
    var  subject = document.getElementById("subject").value;
var  prelim = document.getElementById("prelim").value;
var  midterm = document.getElementById("midterm").value;
var  endterm = document.getElementById("endterm").value;
     solve_prelim = parseFloat(prelim) * 0.20;
solve_midterm = parseFloat(midterm) * 0.30;
solve_endterm = parseFloat(endterm) * 0.50;
   
      final_grade  = (solve_prelim + solve_midterm + solve_endterm);
 
 if (final_grade >= 75) {
    remarks = "PASSED";
    results = "In your subject " +subject +"."
         results2= " Your final grade is " + final_grade.toFixed(0) + ".";
results3 = " You " + remarks + " the subject."; 
 
}
else {
 remarks="FAILED";
 results = "In your subject " +subject + ".";
 results2= " Your final grade is " + final_grade.toFixed(0) + ".";
 results3="You " + remarks + " the subject."; 
 
 } 
   
          document.getElementById("demo").innerHTML = results;
 document.getElementById("demo2").innerHTML = results2;
 document.getElementById("demo3").innerHTML = results3;
  }
</script>
</body>

</html>