kW to Amps Calculator Create Using JavaScript With HTML

Hello Friends Today, through this tutorial, I will tell you How to Write Program kW to Amps calculator using JavaScript with HTML? Below is an example of a kW to Amps calculator using JavaScript with HTML. This calculator allows users to input the power in kilowatts (kW) and the voltage in volts (V) to calculate the corresponding amperage (A).

index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>kW to Amps Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
label {
display: block;
margin-bottom: 8px;
}
input {
width: 100%;
padding: 8px;
margin-bottom: 16px;
box-sizing: border-box;
}
button {
background-color: #4CAF50;
color: white;
padding: 10px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h2>kW to Amps Calculator</h2>
<label for="power">Enter Power (kW):</label>
<input type="number" id="power" placeholder="Enter power in kW">
<label for="voltage">Enter Voltage (V):</label>
<input type="number" id="voltage" placeholder="Enter voltage in V">
<button onclick="calculateAmps()">Calculate Amps</button>
<p id="result"></p>

<script>
function calculateAmps() {

// Get the power input value (kW)
const powerKW = parseFloat(document.getElementById('power').value);

// Get the voltage input value (V)
const voltage = parseFloat(document.getElementById('voltage').value);

// Calculate amperage (A)
const amps = (powerKW * 1000) / voltage;

// Display the result
document.getElementById('result').innerHTML = `Amperage (A): ${amps.toFixed(2)} A`;

}
</script>
</body>
</html>

In this HTML file, users can input the power in kilowatts (kW) and the voltage in volts (V). When the “Calculate Amps” button is clicked, the `calculateAmps` function is called. This function calculates the amperage using the formula:

Amperage (A)= Power (kW)×1000/Voltage (V)

The result is displayed below the button. Adjust the voltage variable based on your specific application.