0% found this document useful (0 votes)
8 views5 pages

Design

The document outlines a C++ program that allows users to select from three options: generating random numbers, using a predefined array, or exiting the program. It includes input validation to ensure only valid options (A, B, or C) are accepted, and provides functionality to determine the mode of the generated or predefined numbers. The document also includes a data format section and pseudo code for implementation.

Uploaded by

manesakamohelo
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Design

The document outlines a C++ program that allows users to select from three options: generating random numbers, using a predefined array, or exiting the program. It includes input validation to ensure only valid options (A, B, or C) are accepted, and provides functionality to determine the mode of the generated or predefined numbers. The document also includes a data format section and pseudo code for implementation.

Uploaded by

manesakamohelo
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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)

chchoiceUser 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

You might also like