You are a programmer for A Big Company. You have been asked to create a program that displays on the screen the weekly payroll report.
The input is to be the employee's name, number and weekly sales.
The report is to output the employee's name, number and gross pay. ABC has twenty employees.
The weekly salary for each employee is calculated in the following manner:
each employee receives a $300 base salary,
a 15% commission on the first $500 of sales and
a 10% commission on sales over $500. You have been asked to write this program in C++.
Your supervisor wants both a modular and a non-modular design written with pseudo code and a structure chart for the modular design.
Create a sample input and output screen to be included in the specification document.
Create some test values to be used in the hand checking for each of the design and coding documents and then to be used in the Testing Phase of the C++ program by Quality Assurance.
(a) Non-Modular Design:
Before you look at the examples, try to create the design part on your own.
Now that you have created the pseudo code, click for the pc_payroll of a non-modular design. Are there any global variable? Are there local variables? How can you tell?
Before you look at the example, try to create the C++ program on your own. Try to use the Design document to write the program.
Click for the payroll.cpp of a non-modular design. Did the design help you to write the program? Are there any global variable? Are there local variables? How can you tell?
Copy the program above into your compiler, compile and run it on the test data you created in the Specification Phase.
Notice that the pseudo code used a DO/WHILE preceded by an initialization statement and the program used a for(). As you recall, these two constructs achieve the same results.
(b) Modular Design:
Before you look at the examples, try to create each of the design parts on your own.
Click for the sc_payroll2 for a modular design: Are there any data flow lines? Should there be? Why?
Click for the pc_payroll2 design for a modular design:
Before you look at the example, try to create the C++ program on your own. Try to use the Design documents to write the program.
Click the link: payroll2.cpp for the C++ modular design program. Are there any global variable? Are there local variables? How can you tell? Did the design help you in writing the program? Notice that the Initialization module was not in fact a function. Could it be? How would you modify the program to make it a function? Would this be a good idea? Why?
Copy the program above into your compiler, compile and run it on the test data you created above
Be sure that you compare these two different approaches to the program. In addition compare the pseudo code for each approach with the C++ program so that you can see how they are similar and how they are different. To be correct, the design documents should agree with the code in both logic and variable names.
In the program above you will notice that some of the variables are defined outside of all functions and blocks. As discussed above, these variables are called global variables. The global variables are stored in an area of primary memory called the heap and this memory is assigned to these variables until the program ceases. The global variables may be accessed anywhere in the program after they have been defined. That is, these places in memory are accessible within any code anywhere in the program. Notice that some of the other variables are defined inside of the function. Recall that the variables defined in the body are called local variables and their memory is set aside in the stack memory. This stack memory is only set aside as long as the function is executing and they can only be accessed within the function.