Purchase Solution

Inputting Multiple Integers in a Form

Not what you're looking for?

Ask Custom Question

The sum of the lengths of any two sides of a triangle must be greater than the length of the third side. For example, the numbers 3, 4, and 5 can form a triangle because 3+4 > 5, 4+5 > 3, and 5+3 > 4. In contrast, the numbers 1, 2, and 5 cannot form a triangle because 1+2 < 5. Thus, if you are given any three integers, you can determine whether they could possibly form a triangle or not by applying this general principle.

Write a JavaScript program that allows a user to input three integers using text boxes in a form. (Hint: You need to use the built-in parseInt function to convert the input strings to integers.) Test the three integers to determine if they can be formed into a triangle using the rule given above. Also test if the resulting triangle would be a right triangle using the Pythagorean theorem, namely that the square of the hypotenuse (the longest side) equals the sum of squares of the other two sides. Display an alert box to inform the user whether their integers can form a triangle or a right triangle (tell them which), or if the integers cannot form a triangle. Continue accepting sets of three integers and testing them until the user decides to quit.

Purchase this Solution

Solution Summary

The input multiple integers in a form are examined. The expert writes a JavaScript function.

Purchase this Solution


Free BrainMass Quizzes
Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Basic Networking Questions

This quiz consists of some basic networking questions.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.