CST1801 Visual Basic I
Lab Week 4


Exercises

Exercise 5.6  (Pythagorean Triples) (10 points)

A right triangle can have sides that are all Integers.  A set of three Integer values for the sides of a right triangle is called a Pythagorean triple.  These three sides must satisfy the relationship that the sum of the squares of two of the sides is equal to the square of the hypotenuse.  Write a program to find all Pythagorean triples for side1, side2, and the hypotenuse, all no larger than 500.  Use a triple-nested for loop that tries all possibilities.  The is an example of "brute force" computing.  Display your answers formatted nicely in a ListBox.

Hint: side a squared plus side b squared equals the hypotenuse squared in a right triangle.  So a2 + b2 = c2

  Result (Save to your local machine and run)

Note: Extra credit if you display the elapsed time for the program to compute the solution (4 points).

Comparison of execution times for the above exercise.

C# .NET
Visual Basic .NET
C++ .NET
C++ console
Visual Basic 6 compiled to native code
Java applet

Exercise 8.8  Multiplication table (10 points)

Write a program that to display a multiplication table in a textbox.  The program should be capable of displaying a table of any size, specified by an integer entered into a text box.  Use the library tab property.

  Result (Save to your local machine and run)

Exercise 8.10  Sum of series EC Extra credit (10 points)

Write a program to calculate and display the sum of the series:

1 - 1/2 + 1/3 - 1/4 + ...

until a term is reached that is less than 0.0001.

  Result (Save to your local machine and run)