Question

*JAVASCRIPT QUESTION* Write a JavaScript program that calculates the area and perimeter of a square. Use...

*JAVASCRIPT QUESTION*

Write a JavaScript program that calculates the area and perimeter of a square.

Use document.write() for output.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

<html>
<head>
<title>AREA AND PERIMETER OF A SQUARE</title>
</head>
<body>
<script language="JavaScript">
    function SQUARE()
    {
      var SIDE =document.FORM.TXTSIDES.value;
      document.write("<P>THE ARE OF SQUARE= " + (SIDE*SIDE) + "</p>");
      document.write("<P>THE PARIMETER OF SQUARE= " + (4* SIDE) + "</p>");
    }
    </script>
    <form NAME=FORM>
    ENTER SIDES OF SQUARE:
       <input TYPE="text" NAME="TXTSIDES" size=20>
       <br>
       <input TYPE="button" VALUE="CALCULATE" ONClick='SQUARE();'>
</form>
</script>
</body>
</html>

Add a comment
Know the answer?
Add Answer to:
*JAVASCRIPT QUESTION* Write a JavaScript program that calculates the area and perimeter of a square. Use...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write a program that determines the area and perimeter of a square. Your program should...

    1. Write a program that determines the area and perimeter of a square. Your program should accept the appropriate measurement of the square as input from the user and display the result to the screen. Area of Square = L (squared) Perimeter of Square = 4 * L 2.  Write a program that determines the area and circumference of a circle. Your program should accept the appropriate measurement of the circle as input from the user and display the result to...

  • Q2) Interface Create a program that calculates the perimeter and the area of any given 2D...

    Q2) Interface Create a program that calculates the perimeter and the area of any given 2D shape. The program should dynamically assign the appropriate calculation for the given shape. The type of shapes are the following: • Quadrilateral 0 Square . Perimeter: 4xL • Area:LXL O Rectangle • Perimeter: 2(L+W) • Area:LxW Circle Circumference: I x Diameter (TT = 3.14) Area: (TT xD')/4 Triangle (assume right triangle) o Perimeter: a+b+c O Area: 0.5 x base x height (hint: the base...

  • write a c programming Write a program that will calculate the perimeter, area and volume of...

    write a c programming Write a program that will calculate the perimeter, area and volume of a is is entered by the user. Your program will display the radius, perimeter, area and volume to the monitor and will also save them to a file called "circlePAV.txt". Your program should prompt the user for the radius until the user enters -1. Use the following structure. typedef struct ( float radius; float area, float perimeter; float volume; ylinder Figure>

  • Write a JavaScript program to calculate Area of a trapezoid Equation: Area = (top side +...

    Write a JavaScript program to calculate Area of a trapezoid Equation: Area = (top side + bottom side) * height / 2 1. Use prompt() function to take top side, bottom side, and height values from user 2. For validation, if user did not put in a number, your program must send out 3. "Input must be number" error message using alert() function. 4. If user put in all numbers, use alert() function to output correct answer

  • Write a JavaScript program to calculate Area of a trapezoid Equation: Area = (top side +...

    Write a JavaScript program to calculate Area of a trapezoid Equation: Area = (top side + bottom side) * height / 2 1. Use prompt() function to take top side, bottom side, and height values from user 2. For validation, if user did not put in a number, your program must send out 3. "Input must be number" error message using alert() function. 4. If user put in all numbers, use alert() function to output correct answer

  • Calculate the area and perimeter(circumference) of a circle. Print the area and perimeter(circumference) Use a radius...

    Calculate the area and perimeter(circumference) of a circle. Print the area and perimeter(circumference) Use a radius of 15 to test your program, calculations should have 2 decimal places. In C++, please use visual studios, and show the output.

  • Java Write a program to print the perimeter and area of rectangles using all combinations of...

    Java Write a program to print the perimeter and area of rectangles using all combinations of heights and widths running from 1 foot to 10 feet in increments of 1 foot. Print the output in headed, formatted columns.

  • 5. (30 pts) Write a program that calculates the surface area of a cube (see the...

    5. (30 pts) Write a program that calculates the surface area of a cube (see the formula below). The user inputs the cube's side length and your program will then print out the surface area of that cube. Your code must follow the output in the sample run below. Your program must be complete and correct, but you do not need to include comments. Here is the formula to calculate surface area given a cube's side length: surface area 6...

  • I need help with a javascript assignment: Write a program called sum_number.js, that calculates the sum...

    I need help with a javascript assignment: Write a program called sum_number.js, that calculates the sum of the numbers contained in a string and displays the result. Use a string containing “2155” as your input value. For example, given the input , let num = “22”, I would sum 2 + 2 for a result of 4. The power is the amps at a given hour times the voltage at the same hour. Calculate the average power consumed for the...

  • a. If the area of a square is 625 cm2, what is its perimeter? b. If...

    a. If the area of a square is 625 cm2, what is its perimeter? b. If the perimeter of a square is 40 cm, what is its area? a. The perimeter of the square is b. The area of the square is

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT