-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bb22f7
commit a9e3771
Showing
4 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
Calculators/Electric-Vehicle-Savings-Calculator/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Electric Vehicle Savings Calculator</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>EV Savings Calculator</h1> | ||
<form id="calculator-form"> | ||
<label for="petrol-avg">Petrol Vehicle Efficiency (kms/l):</label> | ||
<input type="number" id="petrol-avg" step="0.1" placeholder="e.g. 12"> | ||
|
||
<label for="battery-cap">EV Battery Capacity (kWh):</label> | ||
<input type="number" id="battery-cap" step="0.1" placeholder="e.g. 50"> | ||
|
||
<label for="ev-range">EV Range (kms):</label> | ||
<input type="number" id="ev-range" step="1" placeholder="e.g. 300"> | ||
|
||
<label for="elec-cost">Cost of Electricity per kWh:</label> | ||
<input type="number" id="elec-cost" step="0.01" placeholder="e.g. 0.20"> | ||
|
||
<button type="button" onclick="calculateCosts()">Calculate</button> | ||
</form> | ||
|
||
<div class="result"> | ||
<h3>Results</h3> | ||
<p id="petrol-cost">Petrol Vehicle Cost per km: </p> | ||
<p id="ev-cost">Electric Vehicle Cost per km: </p> | ||
</div> | ||
</div> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function calculateCosts() { | ||
const petrolAvg = parseFloat(document.getElementById("petrol-avg").value); | ||
const batteryCap = parseFloat(document.getElementById("battery-cap").value); | ||
const evRange = parseFloat(document.getElementById("ev-range").value); | ||
const elecCost = parseFloat(document.getElementById("elec-cost").value); | ||
|
||
if ( | ||
isNaN(petrolAvg) || | ||
isNaN(batteryCap) || | ||
isNaN(evRange) || | ||
isNaN(elecCost) | ||
) { | ||
alert("Please enter valid numbers for all fields."); | ||
return; | ||
} | ||
|
||
// Petrol cost per km considering average petrol price in India | ||
const petrolCostPerKm = ((1 / petrolAvg) * 100).toFixed(2); // Assuming an average fuel price of ₹100 per liter | ||
const evCostPerKm = ((elecCost * batteryCap) / evRange).toFixed(2); | ||
|
||
document.getElementById( | ||
"petrol-cost" | ||
).innerText = `Petrol Vehicle Cost per km: ₹${petrolCostPerKm}`; | ||
document.getElementById( | ||
"ev-cost" | ||
).innerText = `Electric Vehicle Cost per km: ₹${evCostPerKm}`; | ||
} |
83 changes: 83 additions & 0 deletions
83
Calculators/Electric-Vehicle-Savings-Calculator/styles.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
body { | ||
font-family: 'Arial', sans-serif; | ||
background-color: #a6a6f0; /* Light background color for contrast */ | ||
color: #333; /* Darker text color for better readability */ | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
.container { | ||
background-color: #ffffff; /* White background for the container */ | ||
padding: 40px; | ||
border-radius: 12px; /* Rounded corners */ | ||
width: 400px; /* Slightly wider container */ | ||
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2); /* Enhanced shadow for depth */ | ||
border: 1px solid #e0e0e0; /* Light border for better separation */ | ||
} | ||
|
||
h1 { | ||
font-size: 1.8em; | ||
margin-bottom: 20px; /* Added space below heading */ | ||
text-align: center; | ||
color: #007bff; /* Bright blue for heading */ | ||
} | ||
|
||
form { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
label { | ||
margin-bottom: 5px; /* Spacing between label and input */ | ||
font-weight: 600; /* Slightly bolder font weight */ | ||
color: #555; /* Darker color for labels */ | ||
} | ||
|
||
input, button { | ||
width: 100%; /* Full width for inputs and button */ | ||
padding: 14px; | ||
margin-bottom: 15px; /* Space between elements */ | ||
border: 1px solid #ccc; /* Light gray border */ | ||
border-radius: 6px; /* Rounded corners */ | ||
background-color: #f9f9f9; /* Lighter background for inputs and button */ | ||
color: #333; /* Darker text color for readability */ | ||
font-size: 1em; /* Consistent font size */ | ||
} | ||
|
||
input:focus, button:focus { | ||
outline: none; | ||
border-color: #007bff; /* Highlight border color on focus */ | ||
box-shadow: 0 0 8px rgba(0, 123, 255, 0.5); /* Enhanced shadow on focus */ | ||
} | ||
|
||
button { | ||
background-color: #5959f8; | ||
border: none; | ||
color: #ffffff; /* White text color for button */ | ||
cursor: pointer; | ||
font-weight: bold; | ||
} | ||
|
||
button:hover { | ||
background-color: #014ea0; | ||
} | ||
|
||
.result { | ||
margin-top: 20px; /* Space above results */ | ||
padding-top: 15px; | ||
border-top: 1px solid #e0e0e0; /* Light border for separation */ | ||
} | ||
|
||
.result h3 { | ||
font-size: 1.3em; | ||
margin-bottom: 10px; | ||
color: #007bff; /* Bright blue for result heading */ | ||
} | ||
|
||
.result p { | ||
font-size: 1.1em; | ||
margin: 5px 0; /* Space between result lines */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters