Skip to content

Commit

Permalink
Merge pull request #1901 from falak412/main
Browse files Browse the repository at this point in the history
Added Travel Cost Calculator
  • Loading branch information
PriyaGhosal authored Nov 10, 2024
2 parents f1baeaf + 5d6229c commit 4d93166
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 0 deletions.
114 changes: 114 additions & 0 deletions Calculator.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Travel Cost Calculator</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
}

body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #f4f4f9;
}

.container {
width: 90%;
max-width: 400px;
background: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
text-align: center;
}

h1 {
font-size: 24px;
color: #333;
margin-bottom: 20px;
}

form label {
display: block;
margin: 10px 0 5px;
font-weight: bold;
color: #555;
}

form input {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border-radius: 5px;
border: 1px solid #ddd;
}

button {
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
margin-top: 10px;
}

button:hover {
background-color: #45a049;
}

#result {
margin-top: 20px;
font-size: 18px;
color: #333;
}
</style>
</head>
<body>
<div class="container">
<h1>Travel Cost Calculator</h1>
<form id="travelForm">
<label for="distance">Distance (km):</label>
<input type="number" id="distance" required>

<label for="fuelEfficiency">Fuel Efficiency (km/l):</label>
<input type="number" id="fuelEfficiency" required>

<label for="fuelCost">Fuel Cost (per liter):</label>
<input type="number" id="fuelCost" required>

<button type="button" onclick="calculateCost()">Calculate Cost</button>
</form>
<div id="result"></div>
</div>

<script>
function calculateCost() {
const distance = parseFloat(document.getElementById('distance').value);
const fuelEfficiency = parseFloat(document.getElementById('fuelEfficiency').value);
const fuelCost = parseFloat(document.getElementById('fuelCost').value);

if (isNaN(distance) || isNaN(fuelEfficiency) || isNaN(fuelCost)) {
alert("Please fill out all fields correctly.");
return;
}

// Calculate the cost
const totalCost = (distance / fuelEfficiency) * fuelCost;

// Display the result
document.getElementById('result').innerText = `Total Travel Cost: ₹${totalCost.toFixed(2)}`;
}
</script>
</body>
</html>
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,15 @@ <h2>Our Services</h2>
<a href="guide.html"><h3>Local Guide Connection</h3></a>
<p>Partner with local guides and tour providers, allowing to book personalized tours or experiences led by locals for an authentic travel experience.</p>
</div>

<!-- Travel Cost Calculator-->
<div class="service-card">
<a href="Calculator.html"> <div class="icon">
<i class="fas fa-calculator"></i>
</div></a>
<a href="Calculator.html"><h3>Travel Cost Calculator</h3></a>
<p>The Travel Cost Calculator estimates journey costs based on distance, fuel, and travel mode, helping users plan and budget trips efficiently.</p>
</div>
</div>

</section>
Expand Down

0 comments on commit 4d93166

Please sign in to comment.