# Electricity Bill Tool Create Using JavaScript With HTML

Hello Friends Today, through this tutorial, I will tell you How to create an Electricity Bill Tool using JavaScript with HTML? To create an Electricity Bill Tool using JavaScript with HTML, you can follow this example. This tool calculates the electricity bill based on the provided units and the applicable tariff rates.

index.html

```<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Electricity Bill Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
label {
display: block;
margin-bottom: 8px;
}
input {
width: 100%;
margin-bottom: 16px;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
</style>
<body>
<h2>Electricity Bill Calculator</h2>
<label for="units">Enter Units Consumed:</label>
<input type="number" id="units" placeholder="Enter units consumed">
<button onclick="calculateBill()">Calculate Bill</button>
<p id="result"></p>
<script>
function calculateBill() {
// Get the units input value
const units = parseFloat(document.getElementById('units').value);
// Define tariff rates
const firstSlabRate = 5.0; // Rate for the first 100 units
const secondSlabRate = 7.0; // Rate for units beyond 100
let bill = 0;
// Calculate bill based on slab rates
if(units <= 100) {
bill = units * firstSlabRate;
} else {
bill = (100 * firstSlabRate) + ((units - 100) * secondSlabRate);
}
// Display the result
document.getElementById('result').innerHTML = `Your electricity bill is \$\${bill.toFixed(2)}`;
}
</script>
</body>
</html>```

In this tool, users can input the number of units consumed, and upon clicking the “Calculate Bill” button, the total electricity bill is computed based on predefined slab rates. Adjust the slab rates as per your region’s electricity tariff structure.

Cialis (Tadalafil) är den främsta konkurrenten till Viagra (Sildenafil) på marknaden för erektil dysfunktion. köpa Cialis i Sverige föredras av många på grund av sin längre varaktighet och anses vara det mest kostnadseffektiva varumärkesbaserade ED-läkemedlet som finns tillgängligt i Sverige. Cialis finns i två varianter: Cialis och Cialis Daily, och fyra olika doseringar: 2,5 mg, 5 mg, 10 mg och 20 mg, erbjuder Cialis också en rad olika alternativ för att passa patientens behov.