Write Javascript Program Calculate Area Trapezoid Equation Area Top Side Bottom Side Heigh Q37068756

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


Solution


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

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.