-
Notifications
You must be signed in to change notification settings - Fork 0
/
sem1.html
341 lines (314 loc) · 9.63 KB
/
sem1.html
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<!DOCTYPE html>
<html>
<head>
<title>SGPA Calculator</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link
rel="stylesheet"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
/>
<style>
.form-group {
margin-bottom: 1rem;
}
#result {
color: green;
}
.calculator {
border: 1px solid rgb(179, 179, 179);
border-radius: 0.375rem;
width: 190px;
height: 270px;
font-family: Arial, sans-serif;
margin: 0 auto;
padding: 10px;
}
.output {
border: 1px solid #ccc;
border-radius: 0.375rem;
height: 40px;
margin-bottom: 10px;
margin-top: 10px;
display: flex;
align-items: center;
justify-content: flex-end;
padding-right: 10px;
}
.result {
font-size: 20px;
}
.buttons {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 5px;
}
button {
border: none;
border-radius: 0.375rem;
padding: 10px;
background-color: #eee;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: #ddd;
}
button:active {
background-color: #ccc;
}
.bg-green {
background-color: rgba(0, 177, 29, 0.651);
color: white;
}
.bg-green:hover {
background-color: rgba(0, 231, 39, 0.651);
color: white;
}
.bg-red {
background-color: rgba(223, 4, 4, 0.651);
color: white;
}
.bg-red:hover {
background-color: rgba(255, 1, 1, 0.651);
color: white;
}
</style>
</head>
<body>
<div class="container">
<div class="center">
<h2 class="text-center">1st SEM SGPA Calculator</h2>
</div>
<br />
<div class="calculator">
<div class="output" id="result">
<span class="result"></span>
</div>
<div class="buttons">
<button onclick="addToResult(1)">1</button>
<button onclick="addToResult(2)">2</button>
<button onclick="addToResult(3)">3</button>
<button onclick="addToResult('+')">+</button>
<button onclick="addToResult(4)">4</button>
<button onclick="addToResult(5)">5</button>
<button onclick="addToResult(6)">6</button>
<button onclick="addToResult('-')">-</button>
<button onclick="addToResult(7)">7</button>
<button onclick="addToResult(8)">8</button>
<button onclick="addToResult(9)">9</button>
<button onclick="addToResult('*')">*</button>
<button class="bg-red" onclick="clearResult()">C</button>
<button onclick="addToResult(0)">0</button>
<button class="bg-green" onclick="calculateResult()">=</button>
<button onclick="addToResult('/')">/</button>
</div>
</div>
<script>
let resultElement = document.querySelector(".result");
let currentExpression = "";
function addToResult(value) {
currentExpression += value;
resultElement.textContent = currentExpression;
}
function clearResult() {
currentExpression = "";
resultElement.textContent = "";
document.getElementById("result").textContent = " ";
location.reload();
}
function calculateResult() {
try {
let result = eval(currentExpression);
resultElement.textContent = result;
} catch (error) {
resultElement.textContent = "Error";
}
}
</script>
<br />
<br />
<form>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="input1">Data Structures with Algorithms</label> <br />
<input
type="number"
class="form-control"
id="input1"
placeholder="DSA"
required
/>
</div>
<div class="col-md-6 mb-3">
<label for="input2">Operating System with Unix</label><br />
<input
type="number"
class="form-control"
id="input2"
placeholder="OS/Unix"
required
/>
</div>
<div class="col-md-6 mb-3">
<label for="input3">Computer Networks</label><br />
<input
type="number"
class="form-control"
id="input3"
placeholder="CN"
required
/>
</div>
<div class="col-md-6 mb-3">
<label for="input4"
>Mathematical Foundation for Computer Applications</label
><br />
<input
type="number"
class="form-control"
id="input4"
placeholder="Math Foundation"
required
/>
</div>
<div class="col-md-6 mb-3">
<label for="input5">Research Methodology & IPR</label><br />
<input
type="number"
class="form-control"
id="input5"
placeholder="Research Methodology"
required
/>
</div>
<div class="col-md-6 mb-3">
<label for="input6">Data Structures with Algorithms Lab</label
><br />
<input
type="number"
class="form-control"
id="input6"
placeholder="DSA Lab"
required
/>
</div>
<div class="col-md-6 mb-3">
<label for="input7">Unix Programming Lab</label><br />
<input
type="number"
class="form-control"
id="input7"
placeholder="Unix Lab"
required
/>
</div>
<div class="col-md-6 mb-3">
<label for="input8">Computer Networks Lab</label><br />
<input
type="number"
class="form-control"
id="input8"
placeholder="CN Lab"
required
/>
</div>
</div>
<div class="row">
<div class="col-md-6"></div>
<div class="col-md-6 text-right">
<button
type="button"
class="btn btn-primary btn-lg"
onclick="calculateAndDisplay();"
>
Submit
</button>
</div>
</div>
</form>
</div>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script>
function calculateAndDisplay() {
// Get the values from the input fields
var input1 = parseFloat(document.getElementById("input1").value) || 0;
var input2 = parseFloat(document.getElementById("input2").value) || 0;
var input3 = parseFloat(document.getElementById("input3").value) || 0;
var input4 = parseFloat(document.getElementById("input4").value) || 0;
var input5 = parseFloat(document.getElementById("input5").value) || 0;
var input6 = parseFloat(document.getElementById("input6").value) || 0;
var input7 = parseFloat(document.getElementById("input7").value) || 0;
var input8 = parseFloat(document.getElementById("input8").value) || 0;
function calculateGradePoints(mark) {
if (mark >= 90) {
return 10;
} else if (mark >= 80 && mark <= 89) {
return 9;
} else if (mark >= 70 && mark <= 79) {
return 8;
} else if (mark >= 60 && mark <= 69) {
return 7;
} else if (mark >= 55 && mark <= 59) {
return 6;
} else if (mark >= 50 && mark <= 54) {
return 4;
} else {
return 0; // Grade points for marks below 50
}
}
if (
input1 != " " &&
input2 != " " &&
input3 != " " &&
input4 != " " &&
input5 != " " &&
input6 != " " &&
input7 != " " &&
input8 != " "
) {
if (
input1 > 100 ||
input2 > 100 ||
input3 > 100 ||
input4 > 100 ||
input5 > 100 ||
input6 > 100 ||
input7 > 100 ||
input8 > 100
) {
document.getElementById("result").textContent =
"please enter the marks < 100";
alert("please enter the marks < 100");
location.reload();
} else {
var total1 =
calculateGradePoints(input1) * 4 +
calculateGradePoints(input2) * 4 +
calculateGradePoints(input3) * 4 +
calculateGradePoints(input4) * 4 +
calculateGradePoints(input5) * 2 +
calculateGradePoints(input6) * 2 +
calculateGradePoints(input7) * 2 +
calculateGradePoints(input8) * 2;
var cgpabda = total1 / 24;
cgpa = cgpabda.toFixed(3);
document.getElementById("result").textContent = "SGPA: " + cgpa;
window.scrollTo(0, 0);
}
} else {
document.getElementById("result").textContent =
"Please fill all the fields";
window.scrollTo(0, 0);
}
}
</script>
<h1 id="result"></h1>
<br />
<br />
<br />
<br />
<footer>
<div>© 2023 Manoj and Vignesh. All rights reserved.</div>
</footer>
</body>
</html>