0% found this document useful (0 votes)
43 views7 pages

WP LAB 3-8no

Uploaded by

AV Gamer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views7 pages

WP LAB 3-8no

Uploaded by

AV Gamer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

3.

Write a JavaScript to design a simple calculator to perform the following operations: sum,
product,di erence, and quotient.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
//To Get Input from The user
const num1=parseFloat(prompt("Enter the First Number:"));
const num2=parseFloat(prompt("Enter the Second Number:"));

//To Check IF the input is valid or not


if(isNaN(num1)|| isNaN(num2))
{
alert("Invalid input.Please Enter Valid Numbers.");
}
else
{
//performing calculations
const sum=num1+num2;
const product=num1*num2;
const di erence=num1-num2;
const quotient=num1/num2;
var linebreak="<br/>";

//To Display Results


document.write(`Sum: ${sum}`);
document.write(linebreak);
document.write(`Product: ${product}`);
document.write(linebreak);
document.write(`Di erence: ${di erence}`);
document.write(linebreak);
document.write(`Quotient: ${quotient}`);
}
</script>
</body>
</html>
4.Write a JavaScript that calculates the squares and cubes of the numbers from 0 to 10 and outputs
HTML text that displays the resulting values in an HTML table format.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Square and Cube Table</title>
</head>
<body>
<h2>Square and Cube of Numbers from 0 to 10</h2>
<table border="1" id="resultTable">
<tr>
<th>Number</th>
<th>Square</th>
<th>Cube</th>
</tr>
</table>

<script>
for (let i = 0; i <= 10; i++) {
let square = i * i;
let cube = i * i * i;
document.getElementById('resultTable').innerHTML +=
`<tr>
<td>${i}</td>
<td>${square}</td>
<td>${cube}</td>
</tr>`;
}
</script>
</body>
</html>
5.Write a JavaScript code that displays text “TEXT-GROWING” with increasing font size in the interval
of 100ms in RED COLOR, when the font size reaches 50pt it displays “TEXT-SHRINKING”in BLUE color.
Then the font size decreases to 5pt.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Text Growing and Shrinking</title>
<style>
#text {
color: red; /* Initial color */
font-size: 10pt; /* Starting font size */
transition: font-size 0.1s; /* Smooth transition */
}
</style>
</head>
<body>

<div id="text">TEXT-GROWING</div>

<script>
let fontSize = 10; // Starting font size
const textElement = document.getElementById('text');

const growInterval = setInterval(() => {


if (fontSize < 50) {
fontSize++;
textElement.style.fontSize = fontSize + 'pt';
} else {
clearInterval(growInterval);
textElement.textContent = "TEXT-SHRINKING";
textElement.style.color = 'blue'; // Change color to blue
shrinkText(); // Start shrinking the text
}
}, 100);

function shrinkText() {
fontSize = 50; // Reset to max size to start shrinking
const shrinkInterval = setInterval(() => {
if (fontSize > 5) {
fontSize--;
textElement.style.fontSize = fontSize + 'pt';
} else {
clearInterval(shrinkInterval);
}
}, 100);
}
</script>

</body>
</html>
6. Develop and demonstrate an HTML file that includes a JavaScript script that uses functions for the
following problems:
a. Parameter: A string Output: The position in the string of the left-most vowel
b. Parameter: A number Output: The number with its digits in the reverse order
7.Write a PHP program to keep track of the number of visitors visiting the web page and to display this
count of visitors, with proper headings.
8.Write a PHP program to display a digital clock which displays the current time of the server.

You might also like