project computer science

profilea7madmd
extraCredit_VB_prj2_Submit_Doc11.pdf

Extra Credit Projects

Visual Basic Applications

I. Project 2

Write a Visual Basic program which will find the gross pay, federal tax amount, state tax amount and net

pay when the user supplies a person’s name, the number of hours worked, the hourly rate of pay, the

federal tax percentage, and the state tax percentage for a person:

 Label controls

o Name

o Hours Worked

o Hourly Rate

o State Tax Rate

o Federal Tax Rate

o Gross Pay

o Federal Tax Amount

o State Tax Amount

o Net Pay

 Text Box controls

o empName

o hrsWorked

o hourlyRate

o stTaxRate

o fdTaxRate

o grossPay

 hrsWorked * hourlyRate

o stTax

 grossPay * (stTaxRate / 100)

o fdTax

 grossPay * (fdTaxRate / 100)

o netPay

 grossPay – stTax - fdTax

 Button controls

o Calc

o Clear

o Quit

Specific coding instructions.

CALCULATE PAY

Between the dashed lines below is the code for the Visual Basic Project that

will find the gross pay, state tax amount, federal tax amount and net pay

when the user enters the name, hours worked, hourly pay rate, state tax rate

and federal tax rate entered by the user to the form textbox controls. The

code that you will type is in bold red text. It assumes that the input text

box controls are named as follows:

empName

hrsWorked

hourlyRate

stTaxRate

fdTaxRate

It also assumes that the output text boxe controls are named as follows:

grossPay

stTax

fdTax

netPay

Button controls are assumed to be named as follows:

Calc

Clear

Quit

Remember to add the controls to the form before you begin coding. The code

that you will type is in bold red text. Begin coding by double clicking on

one of the three button controls to enter the code for the click method of

that button control.

---------------------------------------------------------------------------

Public Class Form1

Private Sub Quit_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Quit.Click

End

End Sub

Private Sub Clear_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Clear.Click

empName.Text = ""

hrsWorked.Text = ""

hourlyRate.Text = ""

stTaxRate.Text = ""

fdTaxRate.Text = ""

grossPay.Text = ""

stTax.Text = ""

fdTax.Text = ""

netPay.Text = ""

End Sub

Private Sub Calc_Click(ByVal sender As System.Object, ByVal e As

System.EventArgs) Handles Calc.Click

grossPay.Text = Val(hrsWorked.Text) * Val(hourlyRate.Text)

fdTax.Text = Val(grossPay.Text) * (Val(fdTaxRate.Text) / 100)

stTax.Text = Val(grossPay.Text) * (Val(stTaxRate.Text) / 100)

netPay.Text = Val(grossPay.Text) - Val(fdTax.Text) - Val(stTax.Text)

End Sub

End Class

What to upload:

1. Copy and paste program instruction listing from Visual Basic editor to

a Microsoft Word document. (Your listing should be similar to the one

above)

2. Run the form, enter values into the text boxes and press the Calc

button on your form. Capture the screen by hitting the PrtScr key.

3. Paste the screen capture of the form to the same Word document

containing the program listing.

Submit a printout of the above document with your final exam on the day of the final.