Professional Documents
Culture Documents
2) Following the header, the program statements are in the following order:
pre-processor directives (such as #include <iostream>) main program body variable declarations program statements other functions (Include a header which explains the function)
3) Your programs should also employ good style. This includes appropriate indentation, spacing, and comments. Any user prompts should be simple and descriptive. Write Your C++ Program Write a C++ program that calculates the mean of four numbers entered by the user from the terminal. m = (w + x + y + z)/4 Your program should: a) Prompt the user for the four numbers and read them in. b) Calculate the mean. c) Echo the four numbers back to the terminal. d) Print the mean to the terminal. Three different cases should be examined: Case 1: Declare m, w, x, y, and z to be floats.
Case 2: Declare m to be a float and w, x, y, and z to be ints. Case 3: Use the same variable types as in case 2, except replace the 4 with 4.0 in the denominator of the equation for m. You may write one program that does all the cases or separate programs for each. If you do all the cases in one program, you will need to use more variables than just m, w, x, y, and z. Compile Your Program You should write your program in Microsoft Visual Studio or a similar program. This type of program has both a text editor, and an integrated compiler, so that you can edit your program, compile it, and execute it all in one place. It also has some debugging functions that will allow you to find problems with your code. The TA will show you how to set it up for your program. Run Your Program Enter the following integer values for w, x, y, and z: 3, 7, 1, and 4. Note that these four integers sum to an odd number (15). Use these same four numbers for each of the three cases mentioned above. Report Your Findings Write a memo report using the Suggested Format of Lab Memo Reports (available on Blackboard). In the results section, include your results and an explanation of them in terms of integer division, truncated results, and mixed operations. Your source code and sample input/output for each case should be included as attachments.