<!DOCTYPE html>
<html>
<head>
<title>Task 1.1</title>
<script>
function init() {
var x = parseInt(prompt("Please enter a floor number:"));
var isValid = false;
// Check if input is between 1 and 50
if (x >= 1 && x <= 50) {
// Check for number 13, and digit 4 in ones and tens places
if (x !== 13 && (x % 10 !== 4) && (Math.floor(x / 10) !== 4)) {
isValid = true;
}
}
if (isValid) {
document.getElementById("result").innerHTML = "Welcome! Please enter! Take the elevator to go to floor " + x;
} else {
document.getElementById("result").innerHTML = "Your input " + x + " is NOT a valid floor number!";
}
}
</script>
</head>
<body onload="init();">
<div id="result"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Task 1.2</title>
<script>
function init() {
var i, N, s;
N = 10;
s = "The integers from 1 to " + N + " are listed below: <br/>";
for (i = 1; i <= N; i++) {
s = s + i + "<br/>";
}
document.getElementById("result").innerHTML = s;
}
</script>
</head>
<body onload="init();">
<div id="result"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Task 1.3</title>
<script>
function init() {
var i, N, s, userNum;
N = 10;
userNum = parseInt(prompt("Enter a number to check divisibility:"));
s = "The integers from 1 to " + N + " are listed below: <br/>";
s += "@ the integer is divisible by 2 <br/>";
s += "% the integer is divisible by 5 <br/>";
s += "# the integer is divisible by " + userNum + " <br/>";
for (i = 1; i <= N; i++) {
s = s + i;
if (i % 2 === 0) {
s += "@";
}
if (i % 5 === 0) {
s += "%";
}
if (i % userNum === 0) {
s += "#";
}
s += "<br/>";
}
document.getElementById("result").innerHTML = s;
}
</script>
</head>
<body onload="init();">
<div id="result"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Task 2.1</title>
<script>
function init() {
var x = parseInt(prompt("Please enter a floor number:"));
var isValid = false;
if (x >= 1 && x <= 50) {
if (x !== 13 && (x % 10 !== 4) && (Math.floor(x / 10) !== 4)) {
isValid = true;
}
}
var message = "";
if (isValid) {
message = "Welcome! Please enter! <br/>";
if (x >= 1 && x <= 15) {
message += "Please proceed to take the lift on the left to go to floor " + x;
} else if (x >= 16 && x <= 28) {
message += "Please proceed to take the lift on the middle to go to floor " + x;
} else if (x >= 29 && x <= 50) {
message += "Please proceed to take the lift on the right to go to floor " + x;
}
} else {
message = "Your input " + x + " is NOT a valid floor number!";
}
document.getElementById("result").innerHTML = message;
}
</script>
</head>
<body onload="init();">
<div id="result"></div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Task 2.2</title>
<script>
function init() {
var i, N, s;
N = 50;
s = "The integers from 1 to " + N + " are listed below: <br/>";
s += "^ the integer is divisible by 2 but not divisible by 3 <br/>";
s += "* the integer is a valid floor number <br/>";
for (i = 1; i <= N; i++) {
s += i;
// Divisible by 2 but not 3
if (i % 2 === 0 && i % 3 !== 0) {
s += "^";
}
// Valid floor check
var isValidFloor = false;
if (i !== 13 && (i % 10 !== 4) && (Math.floor(i / 10) !== 4)) {
isValidFloor = true;
}
if (isValidFloor) {
s += "*";
}
s += "<br/>";
}
document.getElementById("result").innerHTML = s;
}
</script>
</head>
<body onload="init();">
<div id="result"></div>
</body>
</html>