Labels

Cerpen (18) html (16) movie (10) modul (7) SAP Security (2) c++ (2) Business (1)

Sunday, 6 March 2016

Calculate GPA in real time

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head><title> This is GPA calculator </title>
<center><h><font size="5" color="blue">This is a program to calculate GPA </font> <h2> </center>
<head>
<script>
function display() {
document.getElementById("displaytot").innerHTML =<input type="text" size="10" name="totcrdthour" disabled="disabled">;
document.getElementById("displaygpa").innerHTML =<input type="text" size="10" name="gpa" disabled="disabled">;
}
</script>
<script type="text/javascript">
<!--
function init() {
document.formInput.num1.focus();
document.formInput.num1.value=0;
document.formInput.num2.value=0;
document.formInput.num3.value=0;
document.formInput.num4.value=0;
document.formInput.num5.value=0;
document.formInput.num6.value=0;
document.formInput.num7.value=0;
document.formInput.num8.value=0;
document.formInput.gpa.value=0;
document.formInput.totcrdthour.value=0;
}
function c() {
var gpa="";
var totcrdthour="";
var num1;
var num2;
var num3;
var num4;
var num5;
var num6;
var num7;
var num8;
num1= parseInt(document.formInput.num1.value);
num2= parseInt(document.formInput.num2.value);
num3= parseInt(document.formInput.num3.value);
num4=parseInt(document.formInput.num4.value);
num5= parseInt(document.formInput.num5.value);
num6= parseInt(document.formInput.num6.value);
num7= parseInt(document.formInput.num7.value);
num8=parseInt(document.formInput.num8.value);
totcrdthour= (num1+num3+num5+num7);
document.formInput.totcrdthour.value=totcrdthour;
gpa= (((num1*num2)+(num3*num4)+(num5*num6)+(num7*num8))/(num1+num3+num5+num7));
document.formInput.gpa.value= gpa;
}
-->
</script>
</head>
<body onload="init();">
<form name="formInput" action="">
<table border=1 width="700px" height="500px">
<tr><td colspan="8" align="center" width="150%"><font size="7"><u> GPA Calculator </u><br></tr>
<tr>
<th>Course Code </th>
<th>Credit hour</th>
<th>Grade</th>
</tr>
<tr>
<td> &nbsp 1. &nbsp <input type="text"> </td>
<td><center><select type="text" name="num1" onchange="c();"> <option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
</select></br></center></td>
<td><center><select type="text" name="num2" onchange="c();"><option value="4.00">A</option>
<option value="3.75">A-</option>
<option value="3.50">B </option>
<option value="3.00">B</option>
<option value="2.50">C </option>
<option value="2.00">C</option>
<option value="1.50">D</option>
<option value="1.00">D</option>
<option value="0.00">F</option>
</select></br> </center></td>
</tr>
<tr>
<td>&nbsp 2. &nbsp <input type="text"> </td>
<td><center><select type="text" name="num3" onchange="c();"> <option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
</select></br></center></td>
<td><center><select type="text" name="num4" onchange="c();"><option value="4.00">A</option>
<option value="3.75">A-</option>
<option value="3.50">B </option>
<option value="3.00">B</option>
<option value="2.50">C </option>
<option value="2.00">C</option>
<option value="1.50">D</option>
<option value="1.00">D</option>
<option value="0.00">F</option>
</select></br> </center></td>
</tr>
<tr>
<td>&nbsp 3. &nbsp <input type="text"> </td>
<td><center><select type="text" name="num5" onchange="c();"> <option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
</select></br></center></td>
<td><center><select type="text" name="num6" onchange="c();"><option value="4.00">A</option>
<option value="3.75">A-</option>
<option value="3.50">B </option>
<option value="3.00">B</option>
<option value="2.50">C </option>
<option value="2.00">C</option>
<option value="1.50">D</option>
<option value="1.00">D</option>
<option value="0.00">F</option>
</select></br> </center></td>
</tr>
<tr>
<td>&nbsp 4. &nbsp <input type="text"> </td>
<td><center><select type="text" name="num7" onchange="c();"> <option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
</select></br></center></td>
<td><center><select type="text" name="num8" onchange="c();"><option value="4.00">A</option>
<option value="3.75">A-</option>
<option value="3.50">B </option>
<option value="3.00">B</option>
<option value="2.50">C </option>
<option value="2.00">C</option>
<option value="1.50">D</option>
<option value="1.00">D</option>
<option value="0.00">F</option>
</select></br> </center></td>
</tr>
<tr><td colspan="1"> &nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp Total credit hour</td><td colspan="4"><center><input type="text" size="10" name="totcrdthour" id="displaytot" disabled="disabled"></center> </td>
<tr><td colspan="1">&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp GPA</td><td colspan="4"> <center><input type="text" size="10" name="gpa" id="displaygpa" disabled="disabled"></center></td>
<tr>
<td colspan='6'>
<center><form action="calcform.asp" method="get">
<input type="reset" id="btnres" name="btnres" value="Reset" />


</form>
</center>
</td>
</tr>
</table>
</form>
<br></br>
<input type="button" onclick="alert('Hi, You should count your gpa!');" value="Click here for a message" />
</body>
</html>

No comments:

Post a Comment