Intermediate Business Programming with C++
Specification:
For an example of a more complete program, suppose you wanted to create a program that receives the student's name, the number tests to average, the grade on each test and then it would calculate the average of this indeterminate number of grades for a student. It should then display the average on the screen with the student's name.
The specification document should contain samples of the input screen and the output screen. Make up a sample input and a sample output screen to meet this requirement.
In addition to the sample data, the specification document should contain sufficient data samples to adequately test the program in the Design, the Coding and the Testing Phase. (Make up some possible values to use for hand testing in the Design Phase, the Coding Phase and for use in the Testing Phase when the program is run.)
Design:
Before you look at the examples, try to create each of the design parts on your own.
-
The structure chart could be like the following: sc_grades Notice the data flow arrows. What do they indicate?
-
The pseudo code of this program could be like the following: pc_grades In what ways does the structure chart help in writing the pseudo code? Are there any global variable? Are there local variables? How can you tell?
Coding:
Before you look at the example program, try to write the program on your own.
-
From the design above, we could therefore create the following C++ program grades.cpp using functions for the modules: Does this C++ program implement the design listed in the Design Phase above? If not, in what ways was it different? Are there any global variable? Are there local variables? How can you tell?
You do not have to store the result of the division in a variable as was done in the pseudo code. The quotient itself could be the output. This will save memory and the time used for the transfer of data to and from the stack memory.
In the above program, the prototype of the function calculateAverage( ) was the declaration and it appears above the function main( ) in which it is called. The definition of calculateAverage( ) was listed after main( ). Remember that the program could be written so that the definition of calculateAverage( ) appeared above main( ). In this way there would be no need for the prototype.
Testing:
Copy this program into your compiler, compile and run it using the test values you developed in the Specification Phase above. In a software company or in the IT department of a large corporation, the Testing Phase would be handled by the Testing/Quality Assurance team.
Maintenance:
What types of changes would you anticipate? Should you make these changes now or wait until you are requested by the user? The answer to this question would depend on the circumstances but be careful of developing modifications that are not requested by the stackholders.
Категории