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...
Module/Week 1 ASSIGNMENT (BASIC ELEMENTS) 1. Install Visual Studio Express 2019 for Windows Desktop (you will...
Module/Week 1 ASSIGNMENT (BASIC ELEMENTS) 1. Install Visual Studio Express 2019 for Windows Desktop (you will need to create a free Microsoft account as part of this process, if you do not already have one). LINK - https://www.visualstudio.com/downloads/ Instructions for installation can be found in the Reading & Study folder of Module/Week 1. 2. Create a new empty project in Visual Studio (VS) called “Hello World,” and then create a new .cpp file called HelloWorld. Into your HelloWorld.cpp file, copy...
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...
VISUAL STUDIO CODE Use a for loop for to create "password". Request the password at least...
VISUAL STUDIO CODE Use a for loop for to create "password". Request the password at least 3 times. If the password is 12345, the procedure ends, if the correct password entered, close excel saving changes. THANKS
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 “Area” project. Create a new Visual Studio Project and call it “Area”. This...
Create a new “Area” project. Create a new Visual Studio Project and call it “Area”. This project will be used to calculate the area of certain figures, like circles, squares and rectangles. So add a title to the Form. The Form Title should say “Area”. Also add 3 labels, 3 Buttons, 3 Textboxes and 3 RadioButtons. The 3 Buttons should be near the bottom of the Form and say “Calc Area”, “Clear” and “Exit”. Make sure to give all your...
This assignment requires you to use at least one loop and an array. You can refer...
This assignment requires you to use at least one loop and an array. You can refer to our book and any programs you have written so far. Make sure that your work is your own. Write a comment at the beginning of your program with your name and your birthday (month and day, does not need to include year). For example: John Doe, May 23 Create an array that will store whole numbers. The size of the array should be...
This assignment requires you to use at least one loop and an array. You can refer...
This assignment requires you to use at least one loop and an array. You can refer to our book and any programs you have written so far. Make sure that your work is your own. Write a comment at the beginning of your program with your name and your birthday (month and day, does not need to include year). For example: John Doe, May 23. Create an array that will store whole numbers. The size of the array should be...
In visual Studio C++ Create a program that uses a for loop to input the high...
In visual Studio C++ Create a program that uses a for loop to input the high temperature, and low temperature for each day of the week. The high and low will be placed into two elements of the array. For each loop the high and low will be placed into the next set of elements of the array. After the temps for all seven days have been entered into the array, a for loop will be used to pull out...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT