Question

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

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

Java Script program:

var top = parseInt(prompt("Enter top side of Trapazoid : "));

var bottom = parseInt(prompt("Enter bottom side of Trapazoid : "));

var height = parseInt(prompt("Enter height of Trapazoid : "));

var area = (top+bottom)*height/2;

if(isNaN(top)|| isNaN(bottom)||isNaN(height))

alert("Input must be number");

else

alert("The area of trapazoid is "+area);

  

if you like the answer please provide a thumbs up.

Add a comment
Know the answer?
Add Answer to:
Write a JavaScript program to calculate Area of a trapezoid Equation: Area = (top side +...
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
  • 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

  • Question 4 Write a program that display the area of a triangle. The program calls the...

    Question 4 Write a program that display the area of a triangle. The program calls the following two functions: .getBaseHeight - This function uses a reference parameter variables to accept a double arguments base and height. This function should ask the user to enter the triangle's buse and height. Input validation: base and height should be positive numbers. calArea - This function should accept the triangle's base and height as arguments and return the triangle's area. The area is calculated...

  • Menu-driven programs will display the menu options to the user and then prompt them for a...

    Menu-driven programs will display the menu options to the user and then prompt them for a menu choice. This program will display the following menu in the following format: Calculator Options: Calculate the area of a circle Calculate the area of a rectangle Calculate the area of a triangle Calculate the area of a trapezoid Calculate the area of a sphere Exit Enter your choice (1-6) Once the user enters a choice for the menu, the program should use a...

  • Problem: Write a short C++ program that gets the side of a cube and the radius...

    Problem: Write a short C++ program that gets the side of a cube and the radius of a sphere from the keyboard and writes to a file the surfaces of these shapes.             ------------------------------------------------------------------------------------------------------------------------ Your task: implement in C++ the algorithm solution shown below. ------------------------------------------------------------------------------------------------------------------------ Part A (79 points) Algorithm solution (in pseudocode): To accomplish this task, your program will have to take the following steps: 1. Declare a variable named outFile that represents an output stream. 2. Declare a...

  • Programing requirement for: Safety Alert System Version 01 I. Project and class name Create a new...

    Programing requirement for: Safety Alert System Version 01 I. Project and class name Create a new project name: yourfirst lastname program01 (you must include your name in the project name) Create a new class name: Safety Alert vo 1 II. Requirement 1. Input Prompt appropriate messages that asking use toenter: city name, season, temperature, and raining. Input validation: your program has to valid the user input and prompt specific message when user enter invalid input. Base on following validation: City...

  • Need help with these scenarios Question 1 Write a JavaScript program to get the volume of...

    Need help with these scenarios Question 1 Write a JavaScript program to get the volume of a Cylinder with four decimal places using object classes. Volume of a cylinder : V = πr2h where r is the radius and h is the height of the cylinder. Your solution must include an HTML and a JavaScript file, with a button to create the cylinder, inputs for the cylinder's radius and height and an output to show the cyclinder's volume. Your solution...

  • 1. Prompt the user for one of the arithmetic operators ('op'): +, -, *,/, or **...

    1. Prompt the user for one of the arithmetic operators ('op'): +, -, *,/, or ** 2. Prompt the user for two input integers ('a' and'b') 3. The input numbers can be positive or negative 4. Perform the arithmetic operation using the two input numbers 5. The first entered number ('a') is the left side, the second ('b') the right side of the operation For exponentiation, the first number is the base, the second the exponent Print (display) the following...

  • In this program, you will be using C++ programming constructs, such as overloaded functions. Write a...

    In this program, you will be using C++ programming constructs, such as overloaded functions. Write a program that requests 3 integers from the user and displays the largest one entered. Your program will then request 3 characters from the user and display the largest character entered. If the user enters a non-alphabetic character, your program will display an error message. You must fill in the body of main() to prompt the user for input, and call the overloaded function showBiggest()...

  • Write a program to compute the area of a triangle using side-angle-side method and reports the...

    Write a program to compute the area of a triangle using side-angle-side method and reports the area of that triangle (rounded to 2 decimal places). Side-angle-side formula: ???? = 1/ 2 ?? sin(?), where a and b are two sides of the triangle, and C is the included angle. Your program must meet the following criteria to receive full marks: • Randomly generate two values between 5 and 10 (inclusive) for two sides a and b of the triangle, respectively....

  • Using C++, Write a program that will provide the user a menu from which the user...

    Using C++, Write a program that will provide the user a menu from which the user may select to calculate the area of one of four geometric shapes: a circle, a rectangle, a triangle, and a trapezoid. You should use the most appropriate SWITCH block for this program. The user will input all data needed to calculate the area. The program should output all data input by the user, the calculated area, and the geometric shape selected. Run this program...

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