UNIVERSITY OF JOHANNESBURG
FACULTY OF SCIENCE
COMPUTER SCIENCE 1A SAMPLE DESIGN
Problem Description
A C++ program that prompts the user to choose between the cases found in the
program namely Option A, B or C each option as its own specific task that it runs, if
the use enters ab invalid input the program will loop until a valid input is entered, it
consists of options like generating random numbers and finding the mode in the
generated sequence, it has a pre-determined numbers and it will determine the mode
int the sequence and the other option is the exit the program.
-(Okgwok, Kabuya)
Input & Output
Input
Input Description Mechanism
Letter A, B or C Standard Input Stream
Output
Output Description Stream (optional)
Option A: Random 1D Array Standard Output Stream
Option B: Predefined 1D Array Standard Output Stream
Option C: Exit Program Standard Output Stream
Data Format
Identifier Data Type Description
int size integer Store the size of the array
blnContinue bool Control execution of do-
while loop
chchoice char Store user’s menu
selection (A, B, C or X)
int mode integer Determines the mode and
prints it
Int modeCount int Counts number of modes
in the array
Pseudo Code
Print (Enter A, B or C)
chchoiceUser input option
While !(chInput)
Print ( Wrong character entered )
Clear error state
Ignore invalid characters in loop
Choice A:
Print(Enter preferred array size)
While!(Input)
Print(Enter a positive number)
Clear error state
Ignore invalid characters in loop
Print(Random positive numbers)
Print(Mode for the random numbers)
Choice B:
Print(Predefined array)
Print(Mode from the predefined array)
Choice C:
Exiting program….
UML Activity Diagram