-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpa.js
43 lines (36 loc) · 1.35 KB
/
gpa.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
function calculateGPA(){
var grades = new Array();
grades[0] = document.getElementById("3153").value; //it_3153
grades[1] = document.getElementById("3503").value; //it_3503
grades[2] = document.getElementById("4153").value; //it_4153
grades[3] = document.getElementById("3883").value; //it_3883
grades[4] = document.getElementById("4323").value; //it_4323
for(var i = 0; i<grades.length;i++){
if(grades[i] === 'A' || grades[i] === 'a'){
grades[i] = 4;
} else if(grades[i] === 'B' || grades[i] === 'b'){
grades[i] = 3;
} else if(grades[i] === 'C' || grades[i] === 'c'){
grades[i] = 2;
} else if(grades[i] === 'D' || grades[i] === 'd'){
grades[i] = 1;
} else {
grades[i] = 0;
}
}
var gpa = 0;
for(var i = 0; i<grades.length;i++){
gpa+=grades[i];
}
gpa /= 5;
var div = document.getElementByID('content');
if (gpa < 3.5){
//$("body").append("<p>We're sorry. Please try again next year!</p>");
var content = document.createTextNode("<p>We're sorry. Please try again next year!</p>");
div.appendChild(content);
} else {
//$("body").append("<p>Congratulations! Please send your resume to <a href=\"mailto:[email protected]\">Curtis White</a></p>");
var content = document.createTextNode("<p>Congratulations! Please send your resume to <a href=\"mailto:[email protected]\">Curtis White</a></p>");
div.appendChild(content);
}
}