(Latest Revision: 08/31/00)
EXAMPLE TOP-LEVEL PROGRAM
/*
THIS IS AN EXAMPLE OF HOW a *top level* PROGRAM SUBMISSION
SHOULD LOOK. IT ILLUSTRATES CORRECT CODING STYLE, CODING
FORMAT, NAMING CONVENTIONS, AND DOCUMENTATION.
*/
/* PROGRAM Stars */
/*
Name: Gordon Goodguy
User Name: goodge
Course: CS 2500, Computer Programming II, Section 003
Instructor: John Sarraille
Date: November 31, 2001
INPUT:
The user of this program inputs a 'y' for yes or a 'n' for no.
OUTPUT:
This program prints a little message and then repeatedly asks
the user if he wants to see a pattern. When the user answers
in the affirmative, it prints the pattern and asks the question
again. When the user answers with 'n', the program stops.
PRECONDITIONS and POSTCONDITIONS: None.
*/
#include <iostream.h>
/*
FUNCTION NAME: PrintMessage ;
INPUT: none.
OUTPUT: a message to the user of this program.
PRECONDITIONS: output set to start on a new line.
POSTCONDITIONS: output set to start on a new line.
CALLERS: the main program
CALLEES: none.
*/
void PrintMessage()
{
/* stub action */
cout << "Here is the message." << endl ;
} ;
/*
FUNCTION NAME: MakePattern ;
INPUT:
the width of the pattern to be made. It is the number of
characters across the middle of the diamond shape.
OUTPUT:
a diamond pattern of asterisks on the computer screen or
standard output.
PRECONDITIONS: output set to start on a new line.
POSTCONDITIONS: output set to start on a new line.
CALLERS: the main program
CALLEES: none
*/
void MakePattern(int widthMP)
{
/* stub action */
cout << "Now here is the diamond pattern of stars." << endl ;
}
main ()
{
char response ;
PrintMessage() ;
do
{
cout << "Would you like to see a pattern? " ;
cout << "Answer y or n: " ;
cin >> response ;
if (response == 'y') MakePattern(15) ;
}
while (response != 'n') ;
}