A School District has its own internal mail. However, it can’t accept packages that
weigh more than 0.5 kg or are larger than 0.2 cubic meters. Write a program that asks the user
to input the weight of a package and its three dimensions (length, width, and height) in meters.
If the package doesn’t meet the requirements, it should say why it failed, otherwise give a
success message.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form action="#">
<label>Length: <input type="number" id="a" required></label>
<label>Width: <input type="number" id="b" required></label>
<label>Height: <input type="number" id="c" required></label>
<input type="submit" id="x" value="Submit" onsubmit="validate()">
</form>
<script>
function validate() {
let a = document.querySelector("#a")
let b = document.querySelector("#b")
let c = document.querySelector("#c")
let volume = 200
if (a * b * c <= volume) {
alert("Success")
} else {
alert("package doesn't meet the requirements")
}
}
</script>
</body>
</html>
Comments
Leave a comment