Computer Science 1511
Computer Science I

Programming Assignment 4
Conditions and Functions (35 points)
Due Thursday, October 28, 1998


This assignment will use conditional statements as well as functions and possibly user-defined functions. As with the previous assignment, your program should be structured into subprograms.

The Problem

Your intrepid 1511 instructor has decided to branch out into the lucrative world of computer instruction. As a first project he wants to create a lot of programs to test people's knowledge about various topics of interest. Your mission (and you have to accept it) is to create one of these test programs. Each test program should provide three sections of three test questions each (for a total of nine questions). At least three of these test questions should have multiple choice answers and three others should have numerical answers. For example, a multiple choice question might look like the following:

  1. The winner of Super Bowl I was the:

    A. Minnesota Vikings
    B. Kansas City Chiefs
    C. Oakland Raiders
    D. Green Bay Packers
    E. None of the above


An example of a question requiring a number answer would be:

  2. What is the record for most TDs thrown in an NFL season?

After each question you should prompt for an answer and then provide feedback based on the answer. For example, if the user typed D as the answer for the multiple choice question above, your program might respond:

  Correct!  Congratulations!

On the other hand, if the user gave an incorrect answer you should note this and indicate the correct response. For example, if the user typed 44 as the answer to the second question above the program might respond:

  Sorry.  The correct answer was 48 (Dan Marino in 1984).

Your program should have questions in three different areas (though the areas may be related). The choice of areas is up to you though it would be helpful if you tried to pick an area that is different from other people's areas (please keep the material at a G or PG rating though).

At the end of the quiz you should print out the users score (out of 9) and a message. If the user correctly answers 7-9 questions you should indicate they pass (you can print out a different answer for each level if you wish). But if the user answers 6 questions correctly and at least one question from each of the three sections you should give them a (tough) makeup question. Otherwise you should indicate the users score and that they need to study some more.

Testing Style

Give some thought to making the program appear to be friendly and easy to use (pretend that someone might really use this program). For example, you should have a short explanation message at the start of the test to tell the user what they are doing. Also, you should try to nicely format the program output so that the questions are easy to read and answer.

Program Structure

You should plan to divide the program up into functions. For example, each of the three sections of the test should be separated into a separate function. Your TA will discuss some possibilities for structuring your program.

What To Hand In

Consult the Programming Assignment Guidelines for information on what to put in the report to go with this program. Note in your structure chart which boxes correspond to functions in your program and the direction information flows. You should also include other samples of your program running (on different data values to demonstrate that it works).