The objective of this homework is to get familiar with the editing and compilation environment, modify a simple C++ program, design a Struct and implement it in a C++ program, and submit to the lab instructor.
Task 1: Familiarize yourself with the IDE.
- Download and install the IDE of your choice. My recommendation is Visual Studio. The community edition is located at https://www.visualstudio.com/downloads/. Make sure you include the C++ language during the setup.
- Create a new project. You can name this whatever you like.
- Type in the code from Gaddis program 8-6 (page 482-484), compile and run the program. (you may choose to download the code from http://wps.pearsoned.com/ecs_gaddis_sowcpp_cs_8/244/62625/16032053.cw/index.html to save yourself some typing.
- Create a breakpoint on line 41 and step through the code until you have displayed two rows of products on the screen.
- Take a screen shot of the output screen and the IDE to include in your lab report.
Task 2: Debugging.
- Create a new project.
- Copy the provided code from the file Lab1-Task2.cpp into your project.
- Compile and run the code.
- Your user has noted the following errors. Fix them.
- The division in the output is incorrect
- The amounts in the division are incorrect. One of the values is a really large negative number that looks like garbage.
- The total is 0 but it shouldn’t be.
- Submit the corrected source code and include a screen shot of the output in your lab report.
Task 3: Structures.
- Reuse the project from task 1.
- Create a structure to replace the 4 arrays in the program (id, units, prices, sales).
- Modify the code in the main function to have a single products array of type defined in step 2.
- Modify the code in the rest of the program to use the single products array rather than the 4 original arrays.
- Submit your working (meaning you tested and removed all bugs) code and include a screen shot of the output in your lab report.
- Write a lab report including the following information:
- A description of the objectives/concepts explored in this assignment including why you think they are important to this course and a career in CS and/or Engineering. Include screen shot(s) from Task 1.
- A description of how you approached debugging Task 2, why you think a programmer may have made the mistakes and how you think they can be avoided in the future. Include screen shot(s) from Task 2.
- A description of what you had to do in Task 3 including any bugs you may have introduced and had to fix. Include screen shot(s) from Task 3.
- Include all source code from Tasks 2 and 3 as well as any special instructions to compile and run those programs.
- Package all files in a single zip folder and submit the file on Canvas.
- TA email: email@example.com.
20% – Lab attendance
30% – Task 2 has been correctly debugged and is displaying the correct output.
30% – Task 3 has been correctly converted to uses a single array of structures instead of multiple arrays and is displaying the correct output.
20% – Lab report contains all required information and is well written.