The payroll clerk at Sun Projects wants an application that computes an employeeâ€™s net pay. The clerk will enter the hours worked and rate of pay. For this application, you do not have to worry about overtime because employees are not allowed to work more than 40 hours. The application should calculate and display the gross pay, federal withholding tax (FWT), Social Security and Medicare tax (FICA), state income tax, and net pay. The FWT is 20% of the gross pay, the FICA tax is 8% of the gross pay, and the state income tax is 2% of the gross pay.
a. List the output, processing (if any), and input items, and then create an appropriate algorithm.
b. Create a Visual Basic Windows application. Use the following names for the solution and project, respectively: Sun Solution and Sun Project. Save the application in the ClearlyVB2012Chap06 folder.
c. Change the name of the form file on your disk to frmMain.vb. If necessary, change the formâ€™s name to frmMain.
d. Create a suitable interface. Include an Exit button.
e. Code the Exit buttonâ€™s Click event procedure and the problemâ€™s algorithm. Use Decimal variables and Decimal named constants. Be sure to use the TryParse method. Format the gross pay and taxes with two decimal places. Format the net pay with a dollar sign and two decimal places.
f. Test the application using 35.5 as the hours worked and 9.56 as the pay rate. The gross pay will be 339.38. The taxes will be 67.88, 27.15, and 6.79. The net pay will be $237.57. Notice that the total of the taxes and net pay differs by a penny from the gross pay. The â€œpenny offâ€ problem occurs because the ToString method rounds the gross pay and taxes before they are displayed. However, the amounts are not rounded when they are used to calculate the net pay. Stop the application.
g. You can fix the â€œpenny offâ€ problem using the Math.Round method. The methodâ€™s syntax is Math.Round(number, decimalPlaces). In the syntax, number is the number to be rounded, and decimalPlaces indicates the number of decimal places to include in the rounding. For example, Math.Round(4.658, 2) evaluates to 4.66. Use the Math.Round method to fix the â€œpenny offâ€ problem.
h. Save the solution and then start the application. Test the application using 35.5 as the hours worked and 9.56 as the pay rate. This time, the net pay is $237.56. Close the Code Editor window and then close the solution.