-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path31Fuel-calculator.html
83 lines (79 loc) · 2.59 KB
/
31Fuel-calculator.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Loan EMI calculator</title>
<style>
input[type=text], select{
width: 50%;
padding: 12px 20px;
margin: 8px 0;
display: inline-block;
border: 2px solid rgb(48, 192, 67);
border-radius: 8px;
box-sizing: border-box;
}
label{
font-size: 30px;
font-family: Arial, Helvetica, sans-serif;
}
input[type=submit]{
width: 15%;
background-color: rgb(101, 252, 41);
color: rgb(240, 245, 244);
padding: 14px 20px;
margin: 8px 0;
border: none;
border-radius: 8px;
cursor: pointer;
font-size: 20px;
font-family: Arial, Helvetica, sans-serif;
}
input[type=submit]:hover{
background-color: rgb(247, 41, 34);
}
div {
border-radius: 9px;
background-color: rgb(23, 177, 126);
padding: 20px;
}
</style>
</head>
<body>
<center>
<h1>FUEL CALCULATOR</h1>
<div>
<form action="" onsubmit="return false">
<label for="km">Enter Total Kilometer :</label>
<input type="text" id="totalkm">
<br>
<label for="milage">Enter Vehicle Milage :</label>
<input type="text" id="milage">
<br>
<label for="fuelprice">Enter Fuel Price :</label>
<input type="text" id="fuel_price">
<br>
<input type="submit" value="Calculate" onclick="calculate(totalkm.value,milage.value,fuel_price.value);"/>
</form>
</div>
<label for="output" id="demo"></label>
<script>
function calculate(a,b,c){
let totalkm = parseInt(a);
let milage = parseInt(b);
let fuel_price = parseFloat(c);
let x = ((totalkm/milage) * fuel_price);
let y = totalkm/milage;
let Total_cost = x.toFixed(2);
let total_fule = y.toFixed(2);
/*let Total_cost = ((totalkm/milage) * fuel_price).toFixed(2);
let total_fule = totalkm/milage.toFixed(2);*/
document.getElementById("demo").innerHTML= "Fuel needed :" + "<b>" + total_fule + "Liters" + "</b>"
+ "<br>" + "Fuel cost :" + Total_cost + " Rs" + "</b>";
}
</script>
</center>
</body>
</html>