-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmax3.html
More file actions
42 lines (32 loc) · 1.17 KB
/
max3.html
File metadata and controls
42 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html>
<head>
<title>Maximum of Three Numbers</title>
</head>
<body>
<h2>Find the Maximum of Three Numbers</h2>
<form>
<label>Enter first number:</label><br>
<input type="number" id="num1" placeholder="Enter number 1"><br><br>
<label>Enter second number:</label><br>
<input type="number" id="num2" placeholder="Enter number 2"><br><br>
<label>Enter third number:</label><br>
<input type="number" id="num3" placeholder="Enter number 3"><br><br>
<input type="button" value="Find Maximum" onclick="findMax()">
</form>
<p id="result"></p>
<script>
function findMax() {
let a = parseFloat(document.getElementById("num1").value);
let b = parseFloat(document.getElementById("num2").value);
let c = parseFloat(document.getElementById("num3").value);
if (isNaN(a) || isNaN(b) || isNaN(c)) {
document.getElementById("result").innerHTML = "Please enter all three numbers.";
return;
}
let max = Math.max(a, b, c);
document.getElementById("result").innerHTML = "The maximum number is: " + max;
}
</script>
</body>
</html>