Assignment JavaScript
Today i will share about my assignment javascript.
Question:
Interactive Creative Design (STIV2053) subject allocates its mark percentage by 60% and 40% where the 60% represents the coursework and the 40% represents the final exam.
Coursework is constituted of quizzes, assignments and a final project which carry the percentage of 10%, 20%, and 30% respectively.
There are 10 quizzes and only the best five are selected to be calculated as a part of the carry mark AUTOMATICALLY. Four assignments must be completed in order to contribute to the carry mark’s total and as for the final project; a complete Interactive Creative Design work along with a written report must be submitted. Both carry the percentages of 20% and 10% respectively.
My assignment is about develop a system that counts the total percentage of the subject and based on the total percentage obtained by using JavaScript + HTML.
Coding
<html>
<head>
<script type="text/javascript">
function Calculate()
{
var quizzes, totalAssignment, totalProject, totalCarryMarkObtained;
var q1 = parseInt(document.getElementById('quiz1').value);
var q2 = parseInt(document.getElementById('quiz2').value);
var q3 = parseInt(document.getElementById('quiz3').value);
var q4 = parseInt(document.getElementById('quiz4').value);
var q5 = parseInt(document.getElementById('quiz5').value);
var q6 = parseInt(document.getElementById('quiz6').value);
var q7 = parseInt(document.getElementById('quiz7').value);
var q8 = parseInt(document.getElementById('quiz8').value);
var q9 = parseInt(document.getElementById('quiz9').value);
var q10 = parseInt(document.getElementById('quiz10').value);
var num = [q1,q2,q3,q4,q5,q6,q7,q8,q9,q10];
num.sort(function(a,b){return a -b});
var totalQuizzes = num[5] + num[6] + num[7] + num[8] + num[9];
quizzes = totalQuizzes /50 * 10;
var a1 = parseInt(document.getElementById('assignment1').value);
var a2 = parseInt(document.getElementById('assignment2').value);
var a3 = parseInt(document.getElementById('assignment3').value);
var a4 = parseInt(document.getElementById('assignment4').value);
totalAssignment = (a1 + a2 + a3 + a4) /100 * 20;
var p1 = parseInt(document.getElementById('projectFull').value);
var p2 = parseInt(document.getElementById('projectReport').value);
totalProject = (p1/100*20) + (p2/10*10);
var final = parseInt(document.getElementById('final').value);
totalCarryMarkObtained= quizzes + totalAssignment + totalProject + final;
alert("Total Carry Mark Obtained = " + totalCarryMarkObtained);
}
</script>
</head>
<body style="background-color:lemonchiffon;">
<h1> <center>STIV2053 Interactive Creative Design STIV2053 <center></h1>
</br>
<table border="2" align="center" width="100%" >
<tr>
<h2><td bgcolor="#ADD8E6"><b><center>Quizzess [10%]<center></b></td></h2>
<td bgcolor="#F08080"><b><center>Assignments [20%]<center></b></td>
<td bgcolor="F0E68C"><b><center>Final Project [30%]<center></b></td>
</tr>
<h2 style="background-color: yellowgreen"> Carry Mark Coursework [60%] </h2>
<tr><td bgcolor="#ADD8E6">
<p> Quiz 1 (10%)          
<input type="text" id="quiz1" size=5 maxlength=2 ></p>
<p> Quiz 2 (10%)          
<input type="text" id="quiz2" size=5 maxlength=2 ></p>
<p> Quiz 3 (10%)          
<input type="text" id="quiz3" size=5 maxlength=2 ></p>
<p> Quiz 4 (10%)          
<input type="text" id="quiz4" size=5 maxlength=2 ></p>
<p> Quiz 5 (10%)          
<input type="text" id="quiz5" size=5 maxlength=2 ></p>
<p> Quiz 6 (10%)          
<input type="text" id="quiz6" size=5 maxlength=2 ></p>
<p> Quiz 7 (10%)          
<input type="text" id="quiz7" size=5 maxlength=2 ></p>
<p> Quiz 8 (10%)          
<input type="text" id="quiz8" size=5 maxlength=2 ></p>
<p> Quiz 9 (10%)          
<input type="text" id="quiz9" size=5 maxlength=2 ></p>
<p> Quiz 10 (10%)          
<input type="text" id="quiz10" size=5 maxlength=2 ></p>
</br>
</td>
<td bgcolor="#F08080">
<p> Assignment 1 (25%)      
<input type="text" id="assignment1" size=5 maxlength=2 ></p>
<p > Assignment 2 (25%)      
<input type="text" id="assignment2" size=5 maxlength=2 ></p>
<p> Assignment 3 (25%)      
<input type="text" id="assignment3" size=5 maxlength=2 ></p>
<p> Assignment 4 (25%)      
<input type="text" id="assignment4" size=5 maxlength=2 ></p>
</br>
</td>
<td bgcolor="F0E68C">
<p> Interactive Creative Design Project (20%)    
<input type="text" id="projectFull" size=5 maxlength=3 ></p>
<p> Interactive Creative Design Report (10%)    
<input type="text" id="projectReport" size=5 maxlength=2 ></p>
</td></tr>
</table>
</br>
</br>
<h2 style="background-color: yellowgreen"> Final Exam [40%]     <input type="text" id="final" size=5 maxlength=3 >
</h2>
</br>
</br>
<input type="button" value="Calculate!" onClick="Calculate()">
</body>
</html>
The Output

Comments
Post a Comment