A program is required to calculate wages for employees of network Ltd. using the following formulae i) Basic salary = No of Hours * hourly rate ii) Lunch Allowance = Ksh. 200.00 iii) Gross Salary = Basic Pay + Lunch Allowance iv) Income Tax charged on gross pay as follows: Gross Tax <2000 0% 2001-3000 5% 3001-4000 7% 4001-5000 9% >5000 11% v) Net pay = Gross pay – Tax Hourly rate and lunch allowance are constant values. The number of hours worked should be read from the keyboard. Write a VB.NET program to implement the process.
Module Module1
Sub Main()
' Tax Hourly rate and lunch allowance are constant values.
Const hourlyRate As Double = 21.5D
'ii) Lunch Allowance = Ksh. 200.00
Dim lunchAllowance As Double = 200D
'Read the number of hours worked from the keyboard.
Console.Write("Enter the number of hours worked: ")
Dim numberHoursWorked As Integer = Integer.Parse(Console.ReadLine())
'i) Basic salary = No of Hours * hourly rate
Dim basicSalary As Double = numberHoursWorked * hourlyRate
'iii) Gross Salary = Basic Pay + Lunch Allowance
Dim grossSalary As Double = basicSalary + lunchAllowance
'iv) Income Tax charged on gross pay as follows:
'Gross Tax <2000 0% 2001-3000 5% 3001-4000 7% 4001-5000 9% >5000 11%
Dim incomeTax As Double = 0
If grossSalary <= 2000 Then
incomeTax = 0
End If
If grossSalary >= 2001 And grossSalary <= 3000 Then
incomeTax = grossSalary * 0.05D
End If
If grossSalary >= 3001 And grossSalary <= 4000 Then
incomeTax = grossSalary * 0.07D
End If
If grossSalary >= 4001 And grossSalary < 5000 Then
incomeTax = grossSalary * 0.09D
End If
If grossSalary >= 5000 Then
incomeTax = grossSalary * 0.11D
End If
'v) Net pay = Gross pay – Tax
Dim netPay As Double = grossSalary - incomeTax
'Display result
Console.WriteLine(vbNewLine + "Hourly rate: Ksh. " + hourlyRate.ToString())
Console.WriteLine("Lunch Allowance: Ksh. 200.00")
Console.WriteLine("The number of hours worked: " + numberHoursWorked.ToString())
Console.WriteLine("Basic salar: Ksh. " + basicSalary.ToString())
Console.WriteLine("Gross Salary: Ksh. " + grossSalary.ToString())
Console.WriteLine("Income Tax: Ksh. " + incomeTax.ToString())
Console.WriteLine("Net pay: Ksh. " + netPay.ToString())
Console.ReadLine()
End Sub
End Module
Comments
Leave a comment