Read and follow the directions below carefully, and perform the steps in the order listed.
- Navigate to your sub-folder: Chapter 01 and rename the Compiler Test.cpp source code file to: Lab 01.cpp
- If you are having problems seeing the file extensions, visit the "Show Hide File Extensions" instructions within the Appendix.
- Start your compiler and open the source code file. Carefully make the following modifcations:
- Change the comments at the top, specifcally:
- The filename should be: Lab 01.cpp
- Purpose should be: Average the weight of three people
- Remove the next 2 lines of comment talking about the main idea
- Author: put your name and erase my name and copyright
- Date: Put today's date
- Remove the next 3 lines of comment dealing with licensing (don't erase the asterisk line)
Note: During the rest of the course you will often use a source code file provided by the instructor as your starting point for a new lab assignment. Sometimes you will use a source code file that you have created as your starting point for a new lab assignment. Either way, you should modify the comments area as appropriate to include at a minimum the four lines of information (filename, purpose, author and date) as established in this lab assignment.
- We are now going to make simple modifcations to this program so that it is able to average the weight of three people. Do the following:
- Within the variables area, change the variable names for age1 and age2 to weight1 and weight2. Add another variable of integer data type with the identifier name of weight3.
- The input area has two prompts and requests for data from the user. They are paired up a prompt and getting data from the keyboard. We need to modify the prompt to ask for weight instead of age. We need to change the variable name from age1 to weight1. Do this for the second pair that prompts and gets the second data item. Create a third pair that prompts and gets the third data item.
- The process area has only one line of code and we need to make changes that add the weight3 and divides by 3.0 instead of 2.0. The code should look like this:
- answer = (weight1 + weight2 + weight3) / 3.0;
- The output area needs the text modifed from ages to weights.
- Build (compile and run) your program. You have successfully written this program if when it run and you put in the three weights; it tells you the correct average.
- After you have successfully written this program, if you are taking this course for college credit, follow the instructions from your professor/instructor for submitting it for grading.