-
Notifications
You must be signed in to change notification settings - Fork 0
/
flowchart.js
164 lines (141 loc) · 4.58 KB
/
flowchart.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
var x = 0;
var ns = 4;
var grad=0,div=0 ;
var sid= new Array;
var eng = new Array();
var math = new Array();
var science = new Array();
var social = new Array();
var pass = new Array(13).fill(0);
var fail = new Array(13).fill(0);
var totstud = new Array(13).fill(0);
var pp=new Array(13).fill(0);
var totstudents=0;
var totalpass=0;
var totalfail=0;
var tpp;
function validate() {
sid[x] = parseInt(document.getElementById("SID").value, 10);
grad = parseInt(document.getElementById("grades").value, 10);
div = parseInt(document.getElementById("div").value, 10);
eng[x] = parseInt(document.getElementById("english").value, 10);
math[x] = parseInt(document.getElementById("maths").value, 10);
science[x] = parseInt(document.getElementById("science").value, 10);
social[x] = parseInt(document.getElementById("social").value, 10);
var g = document.getElementById("grades");
var strUser = g.options[g.selectedIndex].value;
var strUser1 = g.options[g.selectedIndex].text;
var d = document.getElementById("div");
var strUser2 = d.options[d.selectedIndex].value;
var strUser3 = d.options[d.selectedIndex].text;
var b=1;
for(var v=0;v<x;v++)
{
if(sid[v]==sid[x])
{
alert("Student ID already exists");
b=0;
}
}
if (strUser == 0) {
alert("Please select a Grade");
}
else if (strUser2 == 0) {
alert("Please select a division");
}
else if((isNaN(sid[x])))
{
alert("Enter a StudentID")
}
else if(sid[x]<0)
{
alert("Enter a Valid StudentID")
}
else if ((isNaN(eng[x]))) {
alert("Please enter some marks for English ");
}
else if ((isNaN(math[x]))) {
alert("Please enter some marks for Maths ");
}
else if ((isNaN(science[x]))) {
alert("Please enter some marks for Science ");
}
else if ((isNaN(social[x]))) {
alert("Please enter some marks for Social ");
}
else if ((eng[x] < 0) || (math[x] < 0) || (science[x] < 0) || (social[x] < 0)) {
alert("Marks can't be negative");
}
else if ((eng[x] > 100) || (math[x] > 100) || (science[x] > 100) || (social[x] > 100)) {
alert("Marks can't be greater than 100");
}
else if(b==1) {
calculate();
}
}
function clearscreen() {
document.getElementById("SID").value = "";
document.getElementById("grades").value = "";
document.getElementById("div").value = "";
document.getElementById("english").value = "";
document.getElementById("maths").value = "";
document.getElementById("science").value = "";
document.getElementById("social").value = "";
}
function calculate() {
alert("Marks Entered");
var sum = eng[x] + math[x] + science[x] + social[x];
var avg = sum / ns;
if (avg >= 60) {
pass[grad]++;
totstud[grad]++;
totalpass++;
totstudents++;
}
else if (avg < 60) {
fail[grad]++;
totstud[grad]++;
totalfail++;
totstudents++;
}
pp[grad] = ((pass[grad] / totstud[grad]) * 100);
x++;
clearscreen();
if(confirm("Do you wish to continue?!"))
{
//save it
}
else
{
display();
}
}
function display()
{
var myTable = "<h1>Final Report</h1>";
myTable += "<table><tr><td >Grades</td>";
myTable += "<td>No of students</td>";
myTable += "<td>Pass</td>";
myTable += "<td>Fail</td>";
myTable += "<td>Pass Percentage</td></tr>";
for (var i = 1; i <= 12; i++) {
myTable += "<tr><td>Grade" + i + "</td>";
myTable += "<td>" + totstud[i] + "</td>";
myTable += "<td>" + pass[i] + "</td>";
myTable += "<td>" + fail[i] + "</td>";
myTable += "<td>" + pp[i].toFixed(2) + "</td></tr>";
}
if(totstudents==0)
{
tpp=0;
}else{
tpp=(totalpass/totstudents)*100;
}
myTable += "<tr><td>Total</td>";
myTable += "<td>" + totstudents + "</td>";
myTable += "<td>" + totalpass + "</td>";
myTable += "<td>" + totalfail + "</td>";
myTable += "<td>" + tpp.toFixed(2) + "</td>";
myTable += "</table>";
document.getElementById("Result").innerHTML = myTable;
}