Programming Exercise: Looping & Selection
Video Module 8
Due: In lab for full credit, or by October 8, 1995 by 10:00 pm for 70% credit.
Your instructor or TA may ask you to
do this exercise, possibly modified in some way
work on another assignment
Goal of Exercise
The goal of this exercise is to help you understand the flow of control through the Visual Basic SELECT CASE construct. The exercise also illustrates how the decision making process may be repeated in a LOOP.
Background
High School students find History to be very boring. In an attempt to make the subject more interesting, a local High School has asked you to develop a game called "History Pro." This game will help the students learn modern history in an interactive manner. You have to write a program to simulate the game.
Exercise Part One (7 Points)
You are to write a program that does the following tasks:
Welcomes the student to the program
Prompts the student for a year for which he would like historical information
Displays a message indicating the most important event of that year
Wishes the student goodbye
You will use the following dates and events to drive your program:
Year / Event / Importance(*** is most important)
1961-1969 / The Apollo Space Mission / *
1963 / Kennedy was assassinated / ***
1969 / First man on the moon / ***
1969-1974 / CPS130 TA's Were Born! / **
1970-1979 / The '70's were just plain crazy / *
1972 / Watergate Break In / ***
If the user inputs a date that is not covered by this chart, your program will output a message saying that there are no data for the time period.
Exercise Part Two (3 Points)
When you have determined that the SELECT CASE structure is working properly, you should modify the program so that it allows a user to repeat the game as many times as he/she would like. This requires you to enclose the entire SELECT CASE structure in a loop (which?) so that the program runs until the user does not want to learn any more history.
Notes
Here is an example of what the program should look like when it runs.
Computer:Welcome to History Pro
(User clicks on OK)
Computer: Please enter a year for which you wish to see the most important historical event
User enters:1972
Computer:The Watergate Break In
(User clicks on OK)
Computer:Would you like to see history for another year?
(User clicks on YES)
Computer: Please enter a year for which you wish to see the most important historical event
User enters:1973
Computer:CPS130 TA's were born!
(User clicks on OK)
Computer:Would you like to see another year?
(User clicks on NO)
Computer:Thank you for using History Pro
(User clicks on OK)
(Program ends.)
Additional Information
For this lab, you will be using three library modules: FUNCTIONS FUNGetNumber, FUNYesNo and SUB DisplayMessage. You should DECLARE these modules at the beginning of your program.
DECLARE FUNCTION FUNGetNumber (text$, minValue, maxValue)
DECLARE FUNCTION FUNYesNo (text$)
DECLARE SUB DisplayMessage (text$)
Read Appendix C for more information about them.
You must Hand-In your program using the Hand-In program. Make sure you have a header at the top of your Main module.
Save your project under the nameA:HISTORY
Save your file under the nameA:HISTORY