Skip to content

Commit 8cc2607

Browse files
authored
Merge pull request #163 from Chinmay-Dorge/velocity-cal-chinmay-dorge
Velocity Calculator
2 parents 17342c7 + 8510e61 commit 8cc2607

File tree

2 files changed

+202
-0
lines changed

2 files changed

+202
-0
lines changed

VelocityCalc/Chinmay-Dorge/app.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
$(() => {
2+
let btn = $("#btn");
3+
let vel = $("#velocity");
4+
5+
let acc = $("#acc");
6+
7+
let time = $("#time");
8+
let v_unit = false,
9+
a_unit = false,
10+
t_unit = false;
11+
12+
let v1 = $("#v1"),
13+
v2 = $("#v2");
14+
15+
btn.click(() => {
16+
$("#mySelectBox1")
17+
.change(function () {
18+
$("#mySelectBox1 option:selected").each(function () {
19+
let fs = $(this).text();
20+
if (fs == "km/hr") {
21+
v_unit = true;
22+
} else {
23+
v_unit = false;
24+
}
25+
});
26+
})
27+
.trigger("change");
28+
$("#mySelectBox2")
29+
.change(function () {
30+
$("#mySelectBox2 option:selected").each(function () {
31+
let fs = $(this).text();
32+
if (fs == "km/s^2") {
33+
a_unit = true;
34+
} else {
35+
a_unit = false;
36+
}
37+
});
38+
})
39+
.trigger("change");
40+
$("#mySelectBox3")
41+
.change(function () {
42+
$("#mySelectBox3 option:selected").each(function () {
43+
let fs = $(this).text();
44+
if (fs == "hr") {
45+
t_unit = true;
46+
} else {
47+
t_unit = false;
48+
}
49+
});
50+
})
51+
.trigger("change");
52+
53+
let t = 0;
54+
let v = 0;
55+
let a = 0;
56+
57+
if (v_unit) {
58+
v = (5 / 18) * parseFloat(vel.val());
59+
} else {
60+
v = parseFloat(vel.val());
61+
}
62+
if (a_unit) {
63+
a = parseFloat(acc.val()) * 1000;
64+
} else {
65+
a = parseFloat(acc.val());
66+
}
67+
if (t_unit) {
68+
t = parseFloat(time.val()) * 3600;
69+
} else {
70+
t = parseFloat(time.val());
71+
}
72+
73+
CalcVelocity(v, a, t);
74+
75+
function CalcVelocity(v, a, t) {
76+
let res1 = a * t + v;
77+
let res2 = res1 * (18 / 5);
78+
v1.text(`${res2}`);
79+
v2.text(`${res1}`);
80+
}
81+
});
82+
});
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<link
7+
href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css"
8+
rel="stylesheet"
9+
integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU"
10+
crossorigin="anonymous"
11+
/>
12+
<link rel="preconnect" href="https://fonts.googleapis.com">
13+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
14+
<link href="https://fonts.googleapis.com/css2?family=Architects+Daughter&display=swap" rel="stylesheet">
15+
<title>Velocity Calculator</title>
16+
<style>
17+
*{
18+
margin: 5px;
19+
}
20+
body{
21+
background-color: #7EA1C4;
22+
color: #1B365C;
23+
}
24+
.but{
25+
display: flex;
26+
justify-content: center;
27+
}
28+
.font-1{
29+
font-family: 'Architects Daughter', cursive;
30+
margin: 10px 0px 20px 0px;
31+
}
32+
</style>
33+
</head>
34+
<body>
35+
<h1 class="text-center font-1">VELOCITY CALCULATOR</h1>
36+
<form class="container">
37+
<div class="form-group">
38+
<div class="row">
39+
<div class="col 3">
40+
<label for="inputEmail4">Enter Initial Velocity :</label>
41+
</div>
42+
<div class="col 3">
43+
<input type="number" class="form-control" id="velocity" />
44+
</div>
45+
<div class="col 3">
46+
<select id="mySelectBox1" class="form-control">
47+
<option>km/hr</option>
48+
<option selected>m/s</option>
49+
</select>
50+
</div>
51+
</div>
52+
</div>
53+
<div class="form-group">
54+
<div class="row">
55+
<div class="col 3">
56+
<label for="inputEmail4">Acceleration :</label>
57+
</div>
58+
<div class="col 3">
59+
<input type="number" class="form-control" id="acc" />
60+
</div>
61+
<div class="col 3">
62+
<select id="mySelectBox2" class="form-control">
63+
<option id="akm">km/s^2</option>
64+
<option selected id="ams">m/s^2</option>
65+
</select>
66+
</div>
67+
</div>
68+
</div>
69+
<div class="form-group">
70+
<div class="row">
71+
<div class="col 3">
72+
<label for="inputEmail4">Time :</label>
73+
</div>
74+
<div class="col 3">
75+
<input type="number" class="form-control" id="time" />
76+
</div>
77+
<div class="col 3">
78+
<select id="mySelectBox3" class="form-control">
79+
<option id="th">hr</option>
80+
<option selected id="ts">s</option>
81+
</select>
82+
</div>
83+
</div>
84+
</div>
85+
<div class="form-group">
86+
<div class="row">
87+
<div class="col 4">
88+
<label for="inputEmail4">Final Velocity :</label>
89+
</div>
90+
<div class="col 2">
91+
<label id="v1"></label>
92+
</div>
93+
<div class="col 1">
94+
<label>Km/Hr</label>
95+
</div>
96+
<div class="col 2">
97+
<label id="v2"></label>
98+
</div>
99+
<div class="col 1">
100+
<label>m/s</label>
101+
</div>
102+
</div>
103+
<div class="but">
104+
<button id="btn" type="button" class="btn btn-success">
105+
Find Value?
106+
</button>
107+
</div>
108+
</div>
109+
</form>
110+
111+
<script src="app.js"></script>
112+
<script
113+
src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"
114+
integrity="sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ"
115+
crossorigin="anonymous"
116+
></script>
117+
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
118+
<script src="app.js"></script>
119+
</body>
120+
</html>

0 commit comments

Comments
 (0)