-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathconverter.html
124 lines (115 loc) · 3.19 KB
/
converter.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
input[type="number"] {
border: 2px solid black;
padding: 4px;
margin: 10px;
min-width: 50px;
border-radius: 4px;
}
button {
background-color: black;
color: cornsilk;
height: 30px;
}
.container
{
border-radius: 5px;
background-color: #f2f2f2;
padding-top: 4px;
padding-bottom: 20px;
margin-left: 250px;
margin-right: 250px;
}
</style>
<style type="text/css">
h1{
font-family: comic sans ms;
color: purple;
}
</style>
</head>
<body>
<h1 style="text-align: center">10 GPA to 4 GPA Converter</h1>
<br />
<div class="container">
<form style="text-align: center; margin-top: 20px;">
<label>GPA out of 10.00 :</label>
<input
type="number"
id="gpa10"
name="gpa10"
value="0.0"
min="0.0"
step="0.01"
max="10.00"
/>
<br />
<button type="button" onclick="myfunction()" id="btn">Convert</button>
<br />
<label>GPA out of 4 : </label>
<input type="number" id="gpa4" name="gpa4" value="0.0" />
</form>
</div>
<script>
function myfunction() {
var inputgpa = parseFloat(document.getElementById("gpa10").value);
console.log(inputgpa);
var calculatedgpa = 0.0;
if(inputgpa>10.0)
{
alert("Input GPA cannot be greater than 10.00");
}
else if (inputgpa >= 8.5) {
calculatedgpa = 4.0;
} else if (inputgpa >= 8.0) {
calculatedgpa = 3.7;
} else if (inputgpa >= 7.5) {
calculatedgpa = 3.3;
} else if (inputgpa >= 7.0) {
calculatedgpa = 3.0;
} else if (inputgpa >= 6.5) {
calculatedgpa = 2.7;
} else if (inputgpa >= 6.0) {
calculatedgpa = 2.3;
} else if (inputgpa >= 5.5) {
calculatedgpa = 2.0;
} else if (inputgpa >= 5) {
calculatedgpa = 1.7;
} else if (inputgpa >= 4.5) {
calculatedgpa = 1.3;
} else if (inputgpa >= 4.0) {
calculatedgpa = 1.0;
} else {
calculatedgpa = 0.0;
}
if (inputgpa < 0) {
alert("Input GPA can't be negative");
}
document.getElementById("gpa4").value = parseFloat(
calculatedgpa
).toFixed(2);
}
</script>
<script
src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"
></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"
></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"
></script>
</body>
</html>