Question
(VB) Modify the application from Step 1 to ask the user for the number of employees to do payroll for, and use a List to
(VB) Modify the application from Step 1 to ask the user for the number of employees to do payroll for, and use a List to store the number of hours worked by each employee Public Class Form1 Private Sub btnCalcPay_Click(sender As Object, e As EventArgs) Handles btnCalcPay.Click ' Constants Const decHOURLY_PAY_RATE As Decimal = 15D Const intMAX_SUBSCRIPT As Integer = 5 ' Array and other variables Dim dblHoursArray(intMAX_SUBSCRIPT) As Double Dim intCount As Integer = 0 ' Loop counter Dim decEmpPay As Decimal ' To hold gross pay ' Prepare the user to enter each employee's hours. MessageBox.Show("I'm going to ask you for each " & "employee's hours worked.") ' Get the hours worked by the employees. Do While intCount < dblHoursArray.Length Try dblHoursArray(intCount) = CDbl(InputBox("Employee number " & (intCount + 1).ToString())) intCount += 1 Catch ' Display an error message for invalid hours. MessageBox.Show("Enter a valid number of " & "hours for that employee.") End Try Loop ' Clear the list box. lstOutput.Items.Clear() ' Calculate and display each employee's gross pay. For intCount = 0 To dblHoursArray.Length - 1 decEmpPay = CDec(dblHoursArray(intCount) * decHOURLY_PAY_RATE) lstOutput.Items.Add("Employee " & (intCount + 1).ToString() & " earned " & decEmpPay.ToString("c")) Next End Sub
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started