Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Convert pseudocode into Visual Basic code 1 // Constant for the size of the arra

ID: 3912964 • Letter: C

Question

Convert pseudocode into Visual Basic code
1 // Constant for the size of the array. 2 Constant Integer SIZE = 6 3 4 // Array to hold each employee's hours. 5 Declare Real hours[SIZE] 6 7 // Variable to hold the hourly pay rate. 8 Declare Real payRate 9 10 // Variable to hold a gross pay amount. 11 Declare Real grossPay 12 13 // Variable to use as a loop counter. 14 Declare Integer index 15 16 // Get each employee's hours worked. 17 For index = 0 To SIZE - 1 18 Display "Enter the hours worked by" 19 Display "employee ", index + 1, "." 20 Input hours[index] 21 End For 22 23 // Get the hourly pay rate. 24 Display "Enter the hourly pay rate." 25 Input payRate 26 27 // Display each employee's gross pay. 28 Display "Here is each employee's gross pay." 29 For index = 0 To SIZE - 1 30 Set grossPay = hours[index] * payRate 31 Display "Employee ", index + 1, ": $", 32 currencyFormat(grossPay) 33 End For

Programs output should be: Enter the hours worked by employee 1 10 [Enter] Enter the hours worked by employee 2 20 [Enter] Enter the hours worked by employee 3 15 [Enter] Enter the hours worked by employee 4 40 [Enter] Enter the hours worked by employee 5 20 [Enter] Enter the hours worked by employee 6 18 [Enter] Enter the hourly pay rate. 12.75 [Enter] Here is each employee's gross pay. Employee 1: $127.50 Employee 2: $255.00 Employee 3: $191.25 Employee 4: $510.00 Employee 5: $255.00 Employee 6: $229.50
Convert pseudocode into Visual Basic code
1 // Constant for the size of the array. 2 Constant Integer SIZE = 6 3 4 // Array to hold each employee's hours. 5 Declare Real hours[SIZE] 6 7 // Variable to hold the hourly pay rate. 8 Declare Real payRate 9 10 // Variable to hold a gross pay amount. 11 Declare Real grossPay 12 13 // Variable to use as a loop counter. 14 Declare Integer index 15 16 // Get each employee's hours worked. 17 For index = 0 To SIZE - 1 18 Display "Enter the hours worked by" 19 Display "employee ", index + 1, "." 20 Input hours[index] 21 End For 22 23 // Get the hourly pay rate. 24 Display "Enter the hourly pay rate." 25 Input payRate 26 27 // Display each employee's gross pay. 28 Display "Here is each employee's gross pay." 29 For index = 0 To SIZE - 1 30 Set grossPay = hours[index] * payRate 31 Display "Employee ", index + 1, ": $", 32 currencyFormat(grossPay) 33 End For

Programs output should be: Enter the hours worked by employee 1 10 [Enter] Enter the hours worked by employee 2 20 [Enter] Enter the hours worked by employee 3 15 [Enter] Enter the hours worked by employee 4 40 [Enter] Enter the hours worked by employee 5 20 [Enter] Enter the hours worked by employee 6 18 [Enter] Enter the hourly pay rate. 12.75 [Enter] Here is each employee's gross pay. Employee 1: $127.50 Employee 2: $255.00 Employee 3: $191.25 Employee 4: $510.00 Employee 5: $255.00 Employee 6: $229.50
Convert pseudocode into Visual Basic code
1 // Constant for the size of the array. 2 Constant Integer SIZE = 6 3 4 // Array to hold each employee's hours. 5 Declare Real hours[SIZE] 6 7 // Variable to hold the hourly pay rate. 8 Declare Real payRate 9 10 // Variable to hold a gross pay amount. 11 Declare Real grossPay 12 13 // Variable to use as a loop counter. 14 Declare Integer index 15 16 // Get each employee's hours worked. 17 For index = 0 To SIZE - 1 18 Display "Enter the hours worked by" 19 Display "employee ", index + 1, "." 20 Input hours[index] 21 End For 22 23 // Get the hourly pay rate. 24 Display "Enter the hourly pay rate." 25 Input payRate 26 27 // Display each employee's gross pay. 28 Display "Here is each employee's gross pay." 29 For index = 0 To SIZE - 1 30 Set grossPay = hours[index] * payRate 31 Display "Employee ", index + 1, ": $", 32 currencyFormat(grossPay) 33 End For Convert pseudocode into Visual Basic code
1 // Constant for the size of the array. 2 Constant Integer SIZE = 6 3 4 // Array to hold each employee's hours. 5 Declare Real hours[SIZE] 6 7 // Variable to hold the hourly pay rate. 8 Declare Real payRate 9 10 // Variable to hold a gross pay amount. 11 Declare Real grossPay 12 13 // Variable to use as a loop counter. 14 Declare Integer index 15 16 // Get each employee's hours worked. 17 For index = 0 To SIZE - 1 18 Display "Enter the hours worked by" 19 Display "employee ", index + 1, "." 20 Input hours[index] 21 End For 22 23 // Get the hourly pay rate. 24 Display "Enter the hourly pay rate." 25 Input payRate 26 27 // Display each employee's gross pay. 28 Display "Here is each employee's gross pay." 29 For index = 0 To SIZE - 1 30 Set grossPay = hours[index] * payRate 31 Display "Employee ", index + 1, ": $", 32 currencyFormat(grossPay) 33 End For

Programs output should be: Enter the hours worked by employee 1 10 [Enter] Enter the hours worked by employee 2 20 [Enter] Enter the hours worked by employee 3 15 [Enter] Enter the hours worked by employee 4 40 [Enter] Enter the hours worked by employee 5 20 [Enter] Enter the hours worked by employee 6 18 [Enter] Enter the hourly pay rate. 12.75 [Enter] Here is each employee's gross pay. Employee 1: $127.50 Employee 2: $255.00 Employee 3: $191.25 Employee 4: $510.00 Employee 5: $255.00 Employee 6: $229.50 Enter the hours worked by employee 1 10 [Enter] Enter the hours worked by employee 2 20 [Enter] Enter the hours worked by employee 3 15 [Enter] Enter the hours worked by employee 4 40 [Enter] Enter the hours worked by employee 5 20 [Enter] Enter the hours worked by employee 6 18 [Enter] Enter the hourly pay rate. 12.75 [Enter] Here is each employee's gross pay. Employee 1: $127.50 Employee 2: $255.00 Employee 3: $191.25 Employee 4: $510.00 Employee 5: $255.00 Employee 6: $229.50

Explanation / Answer

Please find the code below:

Imports System

Public Module Program
Public Sub Main(args() As string)
Dim SIZE, index as Integer
Dim input as String
SIZE = 6
Dim hours(10) As Double
Dim payRate as Double
Dim grossPay as Double
For index = 0 To SIZE-1
System.Console.WriteLine("Enter the hours worked by employee " + (index + 1) + " : ")
Try
input = System.Console.ReadLine()
hours(index) = Convert.ToDouble(input)
Catch e As FormatException
Console.WriteLine("Unable to convert '{0}' to a Double.", input)   
Catch e As OverflowException
Console.WriteLine("'{0}' is outside the range of a Double.", input)
End Try
Next
  
System.Console.WriteLine("Enter the hourly pay rate : ")
Try
input = System.Console.ReadLine()
payRate = Convert.ToDouble(input)
Catch e As FormatException
Console.WriteLine("Unable to convert '{0}' to a Double.", input)   
Catch e As OverflowException
Console.WriteLine("'{0}' is outside the range of a Double.", input)
End Try
  
System.Console.WriteLine("Here is each employee's gross pay.")
  
For index = 0 To SIZE-1
grossPay = hours(index) * payRate
System.Console.WriteLine("Employee " + (index + 1) + ": $" + grossPay)
Next

End Sub
End Module