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

Exercise 3

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 normal rate, and calculates overtime pay as extra hours times the overtime rate to be added to the regular salary. It then displays the total salary or overtime amount depending on if regular hours exceed 40 hours. A delete button clears all the input and display fields.
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Exercise 3

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 normal rate, and calculates overtime pay as extra hours times the overtime rate to be added to the regular salary. It then displays the total salary or overtime amount depending on if regular hours exceed 40 hours. A delete button clears all the input and display 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

Dim intWorkedHrs As Integer


Dim intExtraHrs As Integer

''Declraration of the Salary

Dim dblSalary As Double


Dim dblExtraSalary As Double

''Rates

Dim dblAmountPerHour = 16.5


Dim 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