CSC 171 LAB #5
FALL 2001
GOAL:
1.
Become
familiar with the switch selection structure
2.
Become
familiar with the for repetition structure
TASKS:
·
Read
and understand the requirements, below
·
Write
pseudocode descriptions of the programs meeting the requirements
·
Implement
your pseudocode in JAVA
·
Demonstrate
the programs
REQUIREMENTS:
Program 1: (Pythagorean Triples) A right triangle
can have sides whose length are all integers. The set of three integer values
for the lengths of the sides of a right triangle is called a Pythagorean
Triple. The lengths of the three sides must satisfy the relationship that the
sum of the squares of two fo the sides is equal to the square of the
hypotenuse. Write and application to find all Pythagorean triples for sides no
larger than 500. Use a triple-nested for loop that tests all possibilities.
Program 2: (“The 12 Days of Christmas” Song) Write
an application that uses repetition and switch structures to print the song
“The Tweleve Days of Christmas”. One switch structure should be used to print
the day (i.e. “First”, “Second”, etc). A separate switch structure should be
used to print the remainder of each verse. Visit the Web site www.12days.com/library/carols/12daysofxmas.htm
for the complete lyrics to the song.
STEPS:
1.
Read
Chapter 5.
2.
By
this point, you should be able to design the program in pseduocode and write
the programs.
3.
Ok, you are done to get credit for all this
work you need to get a piece of paper ready for your lab TA. This paper must
have 2 things on it.
1.
Your
name and lab section
2.
Your
final version of the program with the pseudocode comments
4.
When
you get the paper ready call your lab TA over and demo the program for her/him.
Give the paper to your TA. This completes the hand in process. The deadline is
one week – no late assignments accepted.