Site hosted by Angelfire.com: Build your free website today!

program #9
 

 

 

 

 

 


One of the most famous formulas in math is the Pythagorean theorem: all sides of a right triangle have a relationship a2 + b2 = c2 (a & b are the legs of the triangle and c is the hypotenuse)

 

If you are given any two of the sides, you can find he remaining side.

 

Write a program where you…

a)      find the hypotenuse given the two legs

or

b)      find a leg, given the hypotenuse and the remaining leg.

 

The program will use an ‘if’ statement to select which calculation to perform.

 

First, ask the person to choose a type of calculation, like this…

 

 

 

 

 

 

 

 

 

 

 

 

 


The identifiers will all be doubles.

Have your ‘if’ like this…

if (choice==1)

            {

             do the calculation inside the braces

            }

if (choice==2)

            {

            do the other calculation here

            }

Do not follow where the path may lead.  Go, instead, where there is no path and leave a trail.

                   Anonymous