Sample Prose, Pseudocode and Flowchart for STLSTRINGS program

 

Prepared by C. S. Tritt, Ph.D.

October 11, 2000

 

This document contains sample partial prose, pseudocode and flowchart algorithm descriptions for my stlstrings.cpp program.

 

You should create draft versions of these items before writing your source code. I suggest you complete the final versions once your program is working. Inclusion of both pseudocode and flowcharts in program documentation is redundant. However, I require both in CS-150 because both methods are still used in industry to document algorithms.

 

I use M.S. Word to create these documents. I use Insert | Picture | New Drawing to insert M.S. Draw drawings into Word documents for flowcharts. M.S. Draw has predefined flowchart shapes and a collection of “smart” connectors to connect them.

 

Prose Description

 

This program works by comparing the user input to particular characters in STL string constants and character literals. Specifically, three constants are defined (LARGE, MEDIUM and SMALL) containing the codes (L, M and S, respectively) for the three sizes. Next, the program prompts the user for input and reads their response into the string variable scode. The length of scode is tested and an error message is displayed. If the length of scode is okay, …

 

Pseudocode

 

Include <iostream> and <string>

Define and, or & not for ANSI compatibility

Use namespace std

Start main

            Define string constants LARGE = “L”, MEDIUM = “M” and SMALL = “S”

            Prompt user to enter size

            Read response into scode

            if scode.length => 2

                        Display invalid input message

                        Return 1

            else if scode[0] = LARGE[0]

                        if scode.length = 1 display “Large”

                        else…


Flowchart