Convert pseudocode into Visual Basic code 1 // Constant for the size of the arra
ID: 3914289 • 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
Explanation / Answer
'code for the above pseudo code in visual basics with comments copy and paste in compiler to run it
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text.RegularExpressions
Namespace Rextester
Public Module Program
Public Sub Main(args() As string)
Const SIZE As Integer = 6 'Constant for the size of the array.
Dim hours(SIZE) As Integer 'Array to hold each employee's hours.
Dim payRate As Double ' Variable to hold the hourly pay rate.
Dim grossPay As Double 'Variable to hold a gross pay amount.
'Get each employee's hours worked.
For index As Integer = 0 To SIZE - 1
Console.WriteLine("Enter the hours worked by employee "&index+1)
hours(index) = Console.ReadLine
Next index
'Get the hourly pay rate.
Console.WriteLine("Enter hourly pay rate")
payRate=Console.ReadLine
Console.WriteLine("Here is each employee's gross pay")
'Display each employee's gross pay.
For index As Integer = 0 To SIZE - 1
grossPay=hours(index)*payRate
Console.WriteLine("Employee "& index+1 & ":$" &grossPay)
Next index
End Sub
End Module
End Namespace
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.