0% found this document useful (0 votes)
7 views

Exercise 3.1

This code calculates an employee's salary and overtime pay. It declares variables to store the regular and overtime hours worked, hourly rates, and salary amounts. When the calculate button is clicked, it converts the input hours to integers, calculates the regular salary as hours worked times the hourly rate, and calculates overtime pay as hours over 40 times the overtime rate added to the regular salary. It displays the total salary or overtime salary depending on if regular hours exceed 40. A delete button clears the input and output fields.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Exercise 3.1

This code calculates an employee's salary and overtime pay. It declares variables to store the regular and overtime hours worked, hourly rates, and salary amounts. When the calculate button is clicked, it converts the input hours to integers, calculates the regular salary as hours worked times the hourly rate, and calculates overtime pay as hours over 40 times the overtime rate added to the regular salary. It displays the total salary or overtime salary depending on if regular hours exceed 40. A delete button clears the input and output fields.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Public Class Form1

''Declaration of the Hrs

Private intWorkedHrs As Integer


Private intExtraHrs As Integer

''Declaration of the Salary

Private dblSalary As Double


Private dblExtraSalary As Double

''Rates

Private dblAmountPerHour = 16.5


Private dblAmountExtra = 10

Private Sub btnSalary_Click(sender As Object, e As EventArgs) Handles


btnSalary.Click
''Convertions of Hrs

intWorkedHrs = Convert.ToInt32(txtHrsWorked.Text)
intExtraHrs = Convert.ToInt32(txtExtra.Text)

''Conversion of Salary
dblSalary = Convert.ToDouble(intWorkedHrs * dblAmountPerHour)
dblExtraSalary = Convert.ToInt32((intWorkedHrs * dblAmountPerHour) +
(dblSalary))

''If Statement

If intWorkedHrs > 40 Then


lblDisplayTotal.Text = " Harrys salary for the extra hours he worked is
" + dblExtraSalary.ToString("C2")
Else
lblDisplayTotal.Text = "Total Salary is " + dblSalary.ToString("C2")

End If

End Sub

Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles


btnDelete.Click
lblDisplayTotal.Text = " "
txtHrsWorked.Text = " "
txtExtra.Text = " "
End Sub
End Class

You might also like