0% found this document useful (0 votes)
13 views2 pages

Assigment 2 Internet

The document contains multiple JavaScript code snippets that prompt users for numerical input and perform various operations. It includes comparisons of two numbers, calculations of sum, difference, product, and quotient, as well as checks for positivity, negativity, and evenness of a number. Additionally, there is a snippet for calculating the area and perimeter of a rectangle based on user-provided dimensions.

Uploaded by

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

Assigment 2 Internet

The document contains multiple JavaScript code snippets that prompt users for numerical input and perform various operations. It includes comparisons of two numbers, calculations of sum, difference, product, and quotient, as well as checks for positivity, negativity, and evenness of a number. Additionally, there is a snippet for calculating the area and perimeter of a rectangle based on user-provided dimensions.

Uploaded by

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

1) let number1 = parseFloat(prompt("Enter the first number:"));

let number2 = parseFloat(prompt("Enter the second number:"));

if (number1 > number2) {

alert("The first number (" + number1 + ") is larger than the second
number (" + number2 + ").");

} else if (number1 < number2) {

alert("The first number (" + number1 + ") is smaller than the second
number (" + number2 + ").");

} else {

alert("The first number (" + number1 + ") is equal to the second number
(" + number2 + ").");

2)let number1 = parseFloat(prompt("Enter the first number:"));

let number2 = parseFloat(prompt("Enter the second number:"));

sum

alert("The sum of the numbers is: " + (number1 + number2));

difference

alert("The difference of the numbers is: " + (number1 - number2));

Display the product

alert("The product of the numbers is: " + (number1 * number2));

quotient

if (number2 !== 0) {

alert("The quotient of the numbers is: " + (number1 / number2));

} else {

alert("Division by zero is not allowed.");

3) let number = parseFloat(prompt("Enter a number:"));

if (number > 0) {
alert("The number is positive.");

} else if (number === 0) {

alert("The number is zero.");

} else {

alert("The number is negative.");

4) let number = parseFloat(prompt("Enter a number:"));

if (number > 0) {

alert("The number is positive.");

} else if (number === 0) {

alert("The number is zero.");

} else {

alert("The number is negative.");

if (number % 2 === 0) {

alert("The number is even.");

} else {

alert("The number is odd.");

5) let length = parseFloat(prompt("Enter the length of the rectangle:"));

let width = parseFloat(prompt("Enter the width of the rectangle:"));

let area = length * width;

let perimeter = 2 * (length + width);

alert("The area of the rectangle is: " + area);

alert("The perimeter of the rectangle is: " + perimeter);

You might also like