MCC - CIS162AB - C++ Level I
P02 Weekly Pay - 10 points![]()
The purpose of this assignment is give students an opportunity to review the declaration and uses of variables in calculations. Create a new project (P02) with a soure file (P02.cpp) and text file for sample ouput (output.txt). Refer to P01 Hello World as needed. Enter the source code provided below. Pay attention to declaration and use of the variables and constants, as well as the data types of each of the variables.
- Enter source code presented below into P02.cpp.
Be sure to enter your name where indicated with your name.
![]()
![]()
- When you have completed entering or editing a program, it must be compiled and linked. If the program is entered without any errors, it can be executed.
- Execute your program by selecting Start Without Debugging from the Debug menu.
If the program was entered correctly, the following output will appear in an MS-DOS window.P02 - Your Name Enter the hourly rate and the number of hours worked on the same line, but separated by a space. Press the enter key after entering both values. Enter the hourly rate and hours worked:The program will stop when it gets to the cin statement, because it is waiting for the user to enter a value for rate and hours. When developing and testing programs, the programmer plays both roles, the programmer and user.
For the "Enter the hourly rate and hours worked:" prompt,
enter 9.25, press the space bar, enter 25, and then press the Enter key.
9.25 will be assigned to the first variable listed (rate), and 25 will be assigned hours.
After a program actually produces output, you begin the logic testing. It is a good sign if the programs generates the expected output, but more testing should be conducted. If the correct output is not generated, you'll need to go back, find the error, and edit the program. Then you'll need to compile, link and execute it again to test the new logic.
- The program should generate the following ouput, including the spacing between the labels and values.
If execution does not pause so that the output can be reviewed, be sure to select Start Without Debugging from the Debug menu. If the program matches the required output (including the spacing), capture the sample output and save it in output.txt.
P02 - Your Name Enter the hourly rate and the number of hours worked on the same line, but separated by a space. Press the enter key after entering both values. Enter the hourly rate and hours worked: 9.25 25 Hourly Rate: 9.25 Hours Worked: 25 Gross Pay: 231.25 FICA Tax: 13.88 at 0.06 Federal Tax: 34.69 at 0.15 State Tax: 11.56 at 0.05 Union Dues: 10.00 Net Pay: 161.13 Net Hourly: 6.45 Thank you! Press any key to continue
- The program must be tested with more than one set of values. Continue testing the program by using the three additional cases listed below. Be sure to copy-and-paste the complete output for each case to the same output.txt file for P02.
Cases: Payrate: 12.50 Hours Worked: 40 Payrate: 14.00 Hours Worked: 60 Payrate: 15.00 Hours Worked: 45 You will need to execute the program three additional times to process each case. Sample Output: The following output should be generated and captured. P02 - Your Name Enter the hourly rate and the number of hours worked on the same line, but separated by a space. Press the enter key after entering both values. Enter the hourly rate and hours worked: 12.50 40 Hourly Rate: 12.50 Hours Worked: 40 Gross Pay: 500.00 FICA Tax: 30.00 at 0.06 Federal Tax: 75.00 at 0.15 State Tax: 25.00 at 0.05 Union Dues: 10.00 Net Pay: 360.00 Net Hourly: 9.00 Thank you! P02 - Your Name Enter the hourly rate and the number of hours worked on the same line, but separated by a space. Press the enter key after entering both values. Enter the hourly rate and hours worked: 14 60 Hourly Rate: 14.00 Hours Worked: 60 Gross Pay: 840.00 FICA Tax: 50.40 at 0.06 Federal Tax: 126.00 at 0.15 State Tax: 42.00 at 0.05 Union Dues: 10.00 Net Pay: 611.60 Net Hourly: 10.19 Thank you! P02 - Your Name Enter the hourly rate and the number of hours worked on the same line, but separated by a space. Press the enter key after entering both values. Enter the hourly rate and hours worked: 15 45 Hourly Rate: 15.00 Hours Worked: 45 Gross Pay: 675.00 FICA Tax: 40.50 at 0.06 Federal Tax: 101.25 at 0.15 State Tax: 33.75 at 0.05 Union Dues: 10.00 Net Pay: 489.50 Net Hourly: 10.88 Thank you!
- Submit P02.cpp and output.txt.
See Submitting assignments online.
Revised: 11/01/2010 - www.mc.maricopa.edu/~marquez/cis162ab/p02_weekly_pay.html