This lab gives you another chance to use the debugger and your own detective ability to find and fix the error(s) in a program. Each person is to carry out the lab and copy the solution to the Hw111-2 network drive. Although you work on this lab individually, feel free to ask the members of your group for assistance.
If you already have a workspace on your M drive, use File, Open Workspace to open it. If not, use File, New, Workspace to create a new workspace on your M drive. Then create a new project within it named lab3 by using File, New, Project. Use MyComputer to copy the files in the lab3 folder of your Cs111 network drive to the lab3 directory within your workspace directory on M. (For example, you can use "CTRL click" to select all of the files and then use Edit, Copy, move to the new location and use Edit, Paste.) In Visual Studio, use Project, Add to Project, Files to add these files to the lab3 project.
Use Build, Rebuild All to compile the program. If there are any syntax errors, they should appear in a window at the bottom. Starting at the top of the list of errors, double click on each to bring up the line where the error occurred. (Note that sometimes the error actually occurred on the previous line or even an earlier line. The compiler cannot catch all errors exactly when they occur.) In this program you will get a couple of rather obscure error messages. The third message should be more helpful. Fix any syntax errors that were found. Ask your instructor for help if you cannot tell how to fix an error.
Now let's see if the program works correctly. Logic errors are usually harder to find than syntax errors, as the compiler cannot point them out to you. Read the comments at the top of the program to see what it is expected to do. Then run it with the following input: Use the last name 1, first name 1, ID 1, wage rate 1. Then enter last name 2, first name 2, ID 2, and wage rate 2. Do a similar thing with 3's, then 4's and 5's. When asked for another, press CTRL z and then ENTER. Use the debugger to step over the lines of code in the main function to try to get an idea of where the error is occurring. Watch the values of the variables to see whether they are reasonable. Play detective, looking for clues as to what might be going wrong.
Next, use the debugger to step into one of the helping functions in the program. Then step over the lines of code in the function. Look for clues as to why the program produces the wrong output. In particular, look to see if the average produced is correct for the above data. (Hint: what should the correct average be for 1, 2, 3, 4, 5?)
Note that there is an idiosyncracy of the debugger that may show itself: When dealing with an array parameter in a helping function, the debugger may not be smart enough to know that it should be expandable at index 0, index 1, and so on, even though it will allow you to do this within the function where the array is declared. In the AverageRate function, try to expand EmpArray to see what you get. If it doesn't show you EmpArray[0], EmpArray[1], and so on, then try manually entering EmpArray[0] and EmpArray[1] into a Watch window. (If you do not have a Watch window open, click on the correct button of the Debug toolbar to open a Watch window.)
Once you have found the error in logic, fix things so that the program works correctly.
Use MyComputer to copy your files to the Hw111-2 network drive. Only copy any files that you had to change. Your instructor will look at your work later to see how you have done and to give you a grade for the lab.
Use My Computer to see how much free disk space you have on your M drive. If this is getting to be only a few MB, delete some unneeded files. Do not delete files that are part of your account, such as Desktop, or anything starting with a period character. It is safe to delete any Debug directories as well as files of the form *.ncb and *.opt as they will be regenerated if you recompile the matching C++ program (in a file of the form *.cpp).