<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
label {
display: block;
margin-bottom: 5px;
}
input {
width: 100%;
padding: 8px;
margin-bottom: 15px;
}
button {
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
#result {
margin-top: 20px;
font-weight: bold;
}
</style>
<script>
function calculate() {
var length = parseFloat(document.getElementById('length').value);
var width = parseFloat(document.getElementById('width').value);
var userInput = parseFloat(document.getElementById('userInput').value);
if (!isNaN(length) && !isNaN(width)) {
var area = length * width;
var result = area * 150;
document.getElementById('result').innerText = "The calculated value is: " + result;
} else if (!isNaN(userInput)) {
var result = userInput * 150;
document.getElementById('result').innerText = "The calculated value is: " + result;
} else {
alert("Please enter valid dimensions for the room or a valid number.");
}
}
</script>
<title>Room Area Calculator</title>
</head>
<body>
<h1>Room Area Calculator</h1>
<label for="length">Length of the room:</label>
<input type="number" id="length" placeholder="Enter length">
<label for="width">Width of the room:</label>
<input type="number" id="width" placeholder="Enter width">
<label for="userInput">Enter a pre-calculated value:</label>
<input type="number" id="userInput" placeholder="Enter a number">
<button onclick="calculate()">Calculate</button>
<div id="result"></div>
</body>
</html>