CIS 260 Intro to C++

Hints: Check Printing Project

 

The check printing project is the first program we have attempted that is too big to keep all of the details straight in your head... this is where the design documents become important!

Remember to start with the ALGORITHM! Write out the steps that you need to go through in order to solve the problem. Start with general steps, and use Stepwise refinement (functional decomposition) to break each step into smaller "chunks"

For Example:

GET User Input   // dollars and cents
LOOP WHILE NOT $0.0
	IF dollars > 999
		PRINT_THOUSANDS_OF_DOLLARS
	END IF
	IF dollars > 0
		PRINT_HUNDREDS_OF_DOLLARS
		Print "and cents/100 Dollars"
	ELSE
		Print "Zero and cents/100 Dollars"
	END IF
	GET User Input // next numbers
END LOOP

As you continue breaking the problem into smaller "chunks" eventually you will have a piece that you know how to solve... write the code for that piece as a function! To help you get the details right use a Functional Specification (as discussed in class) to record all of the important specificaitons.

For Example:

Print_digit

Header: void Print_digit( /* in */ int Num2Print )
PreCondition:  Num2Print is assigned && 
			0 <= Num2Print <= 9
PostCondition: Word equivalent of Num2Print has been printed

IF Num2Print == 1 Print "One"
ELSE IF Num2Print == 2 Print "Two"
etc.

A good source for examples of the functional decomposition process is our textbook. At the end of each chapter is a fairly large sample program. Try reading those examples for some good ideas of your own.