Question

In: Computer Science

USE VISUAL STUDIO/VB In this assignment, you will create an array of ten elements, one for...

USE VISUAL STUDIO/VB

In this assignment, you will create an array of ten elements, one for name, one for hours worked,and the last for hourly rate. The arrays will receive the information from inputs from the screen.For example, you will ask the following three questions:

a) Employee name:

b) Hours worked:

c) Hourly rate:

After you have received all ten records and have inserted them into the array, you will then calculate the hourly rate times the hours worked to get gross pay. You will need to calculate overtime if they work more than 40 hours that week. Overtime will be 1.5 per hour over. These calculations should be done in a subroutine. After each calculation, you will print the employee’s name, the hours worked, the rate per hour and the total pay for the week.

Hints: You will need to create three arrays:

a) Dim name() as Char

b) Dim hoursworked() as Double

c) Dim rate() as Double

You will also need for loops to read the information into the array and to write the information to the screen. For example:

a) For I = 0 To 9

console.write(“Enter employee name: ”)

name(I) = console.readln()

next

You will also use a for loop to write the information in the array back out to the screen.

You will also need to create a subroutine to calculate pay. In order to do this, you will need to pass the arrays through the subroutine call. For example you will have two subroutines. One for employees who work 40 hours or less and one for employees who work more than forty hours:

a) Subroutine1 is called regularpay(ByVal array1() as double, ByVal array2() as double,ByVal I as integer)

* Calculation used for this subroutine is as follows: Total = array1 (I) * array2 (I)

b) Subroutine2 is called overtimepay(ByVal array1() as double, ByVal array2() as double,ByVal I as integer)

* Calculation used for this subroutine is a bit more complex, but is as follows: Total= (40 * array2(I)) + ((array1(I) -40)*array2(I)*1.5)

* Return value back to main program.

Solutions

Expert Solution

VB Code:

Module Module1

Sub Main()
'arrays to store employee data
Dim name() As String = New String(10) {}
Dim hoursworked() As Double = New Double(10) {}
Dim rate() As Double = New Double(10) {}
For I = 0 To 9
Console.Write(“Employee ” + Convert.ToString(I + 1) + Constants.vbCrLf)
'getting data from the user
Console.Write(“Enter employee name: ”)
name(I) = Console.ReadLine()
Console.Write(“Enter hours worked: ”)
hoursworked(I) = Console.ReadLine()
Console.Write(“Enter hourly rate: ”)
rate(I) = Console.ReadLine()
Console.Write(Constants.vbCrLf)
Next
'outputing the data
Console.Write(Constants.vbCrLf + "Output: ” + Constants.vbCrLf)
For I = 0 To 9
Console.Write(“Employee ” + Convert.ToString(I + 1) + Constants.vbCrLf)
Console.Write(“Employee name: ” + name(I) + Constants.vbCrLf)
Console.Write(“Hours worked: ” + Convert.ToString(hoursworked(I)) + Constants.vbCrLf)
Console.Write(“Hourly rate: ” + Convert.ToString(rate(I)) + Constants.vbCrLf)
Console.Write(“Gross pay: ”)
'checking if hours worked is greater than 40
If hoursworked(I) > 40 Then
Console.Write(Convert.ToString(overtimepay(hoursworked, rate, I)) + Constants.vbCrLf)
Else
Console.Write(Convert.ToString(regularpay(hoursworked, rate, I)) + Constants.vbCrLf)
End If
Console.Write(Constants.vbCrLf + Constants.vbCrLf)

Next

End Sub

'sub routines
Function regularpay(ByVal array1() As Double, ByVal array2() As Double, ByVal I As Integer)
Dim Total As Double
'calclating regular pay
Total = array1(I) * array2(I)
Return Total
End Function

Function overtimepay(ByVal array1() As Double, ByVal array2() As Double, ByVal I As Integer)
Dim Total As Double
'calculating gross pay
Total = (40 * array2(I)) + ((array1(I) - 40) * array2(I) * 1.5)
Return Total
End Function
End Module

Sample Output:

Employee 1
Enter employee name: emp1
Enter hours worked: 50
Enter hourly rate: 10

Employee 2
Enter employee name: emp2
Enter hours worked: 35
Enter hourly rate: 10

Employee 3
Enter employee name: emp3
Enter hours worked: 40
Enter hourly rate: 15

Employee 4
Enter employee name: emp4
Enter hours worked: 41
Enter hourly rate: 15

Employee 5
Enter employee name: emp5
Enter hours worked: 30
Enter hourly rate: 20

Employee 6
Enter employee name: emp6
Enter hours worked: 30
Enter hourly rate: 15

Employee 7
Enter employee name: emp7
Enter hours worked: 36
Enter hourly rate: 20

Employee 8
Enter employee name: emp8
Enter hours worked: 50
Enter hourly rate: 20

Employee 9
Enter employee name: emp9
Enter hours worked: 50
Enter hourly rate: 18

Employee 10
Enter employee name: emp10
Enter hours worked: 45
Enter hourly rate: 10


Output:
Employee 1
Employee name: emp1
Hours worked: 50
Hourly rate: 10
Gross pay: 550


Employee 2
Employee name: emp2
Hours worked: 35
Hourly rate: 10
Gross pay: 350


Employee 3
Employee name: emp3
Hours worked: 40
Hourly rate: 15
Gross pay: 600


Employee 4
Employee name: emp4
Hours worked: 41
Hourly rate: 15
Gross pay: 622.5


Employee 5
Employee name: emp5
Hours worked: 30
Hourly rate: 20
Gross pay: 600


Employee 6
Employee name: emp6
Hours worked: 30
Hourly rate: 15
Gross pay: 450


Employee 7
Employee name: emp7
Hours worked: 36
Hourly rate: 20
Gross pay: 720


Employee 8
Employee name: emp8
Hours worked: 50
Hourly rate: 20
Gross pay: 1100


Employee 9
Employee name: emp9
Hours worked: 50
Hourly rate: 18
Gross pay: 990


Employee 10
Employee name: emp10
Hours worked: 45
Hourly rate: 10
Gross pay: 475


Related Solutions

USE VISUAL BASIC / VB You will create a datafile with the following information: 70 80...
USE VISUAL BASIC / VB You will create a datafile with the following information: 70 80 90 55 25 62 45 34 76 105You will then write the program to read in the values from the datafile and as you read in each number, you will then evaluate it through an if statement for the weather of the day. For example, when you read in the value 70 from the datafile, you should print to the screen that the temperature...
Use Visual Basic Language In this assignment you will need to create a program that will...
Use Visual Basic Language In this assignment you will need to create a program that will have both a “for statement” and an “if statement”. Your program will read 2 numbers from the input screen and it will determine which is the larger of the 2 numbers. It will do this 10 times. It will also keep track of both the largest and smallest numbers throughout the entire 10 times through the loop. An example of the program would be...
Create a C++ project in visual studio. You can use the C++ project that I uploaded...
Create a C++ project in visual studio. You can use the C++ project that I uploaded to complete this project. 1. Write a function that will accept two integer matrices A and B by reference parameters, and two integers i and j as a value parameter. The function will return an integer m, which is the (i,j)-th coefficient of matrix denoted by A*B (multiplication of A and B). For example, if M = A*B, the function will return m, which...
Use Visual Basic Language In this assignment,you will create the following data file in Notepad: 25...
Use Visual Basic Language In this assignment,you will create the following data file in Notepad: 25 5 1 7 10 21 34 67 29 30 You will call it assignment4.dat and save it in c:\data\lastname\assignment4\. Where lastname is your last name. The assignment will be a console application that will prompt the user for a number. Ex. Console.Write(“Enter a number: ”) And then read in the number Ex. Number = Console.ReadLine() You will then read the data file using a...
Create a new Visual Studio console project named assignment042, and translate the algorithm you developed in...
Create a new Visual Studio console project named assignment042, and translate the algorithm you developed in Assignment 04.1 to C++ code inside the main() function. Your program should prompt for a single 9-digit routing number without spaces between digits as follows: Enter a 9-digit routing number without any spaces: The program should output one of: Routing number is valid Routing number is invalid A C++ loop and integer array could be used to extract the routing number's 9 digits. However...
ASSIGNMENT: Write a program to reverse an array and then find the average of array elements....
ASSIGNMENT: Write a program to reverse an array and then find the average of array elements. Start by creating 2 arrays that can each hold 10 integer values. Then, get values from the user and populate the 1st array. Next, populate the 2nd array with the values from the 1st array in reverse order. Then, average the corresponding elements in the 1st and 2nd arrays to populate a 3rd array (average the 1st element of the 1st array with the...
Create an ASP.Net Website using Visual Studio with C#: Create a simple calculator that has 3...
Create an ASP.Net Website using Visual Studio with C#: Create a simple calculator that has 3 text boxes: 2 of them to enter numbers, the 3rd one displays the results Create 4 buttons to add, subtract, multiply, and divide Prevent the user from entering text in the number fields Display a message indicating “cannot divide by” when the user click “/” and there is a zero the in the second box Create two additional buttons: - One to store data...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of project we have been doing all semester.) Do all of the following in the Program class. You do not need to add any other classes to this project. 2. If it exists, remove the Console.WriteLine(“Hello World!”); line that Visual Studio created in the Program class. 3. At the very top of the Program.cs page you should see using System; On the empty line below...
Create a function to output a one dimensional double array Mwith n elements where the...
Create a function to output a one dimensional double array M with n elements where the first three elements are 1 and each subsequent element is the sum of previous three elements before it. Name the function myArray. Write the function in the correct format to be used to create a Matlab function. Call the function in correct format to output the array with 7 elements.
How to create a two-dimensional array, initializing elements in the array and access an element in...
How to create a two-dimensional array, initializing elements in the array and access an element in the array using PHP, C# and Python? Provide code examples for each of these programming languages. [10pt] PHP C# Python Create a two-dimensional array Initializing elements in the array Access an element in the array
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT