Assignment2 2
Assignment2 2
2
1.Wavesort.html
<!DOCTYPE html>
<html>
<head>
<title>Wave Sort</title>
</head>
<body>
<script>
function waveSort(arr) {
arr.sort((a, b) => a - b);
return arr;
}
</script>
</body>
</html>
2.Multiples.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sum of Multiples</title>
<style>
body{
background-color: cadetblue;
padding-left: 0ch;
text-align: justify;
border-radius: 130;
}
button{
color: rgb(28, 40, 36);
border-bottom: 5cm;
text-align: justify;
text-decoration: solid;
}
</style>
</head>
<body>
<label for="limit">Enter limit:</label>
<input type="number" id="limit">
<button onclick="calculateSum()">Calculate Sum</button>
<p id="result"></p>
<script>
function calculateSum() {
const limit = parseInt(document.getElementById('limit').value);
let sum = 0;
function reverseAndDisplay() {
const originalNumber =
document.getElementById('numberInput').value;
const reversedNumber = reverseNumber(originalNumber);
document.getElementById('result').innerHTML = "Reversed
Number: " + reversedNumber;
}
</script>
</head>
<body>
<h2>Reverse a Number</h2>
<label for="numberInput">Enter a Number:</label>
<input type="text" id="numberInput">
<button onclick="reverseAndDisplay()">Reverse</button>
<p id="result"></p>
</body>
</html>
4.bmi.html
<!DOCTYPE html>
<html>
<head>
<title>BMI Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
background-color: #c6b8b8;
}
#container {
background-color: #847c7c;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(61, 8, 8, 0.1);
}
input[type="text"] {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}
button {
width: 100%;
padding: 10px;
background-color: #59626c;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #536170;
}
#result {
font-weight: bold;
margin-top: 10px;
}
</style>
</head>
<body>
<div id="container">
<h2>BMI Calculator</h2>
<p id="loadingMessage">Welcome</p>
<label for="weight">Weight (kg):</label>
<input type="text" id="weight">
<label for="height">Height (m):</label>
<input type="text" id="height">
<button onclick="calculateBMI()">Calculate BMI</button>
<p id="result"></p>
</div>
<script>
function calculateBMI() {
var weight =
parseFloat(document.getElementById('weight').value);
var height =
parseFloat(document.getElementById('height').value);
var interpretation;
if (bmi < 18.5) {
interpretation = "Underweight";
} else if (bmi >= 18.5 && bmi < 25) {
interpretation = "Normal weight";
} else if (bmi >= 25 && bmi < 30) {
interpretation = "Overweight";
} else {
interpretation = "Obese";
}
document.getElementById('result').innerText = "Your BMI is
" + bmi + ". You are " + interpretation + ".";
}
</script>
</body>
</html>