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...
Using Visual Studio in C#; create a grading application for a class of ten students. The...
Using Visual Studio in C#; create a grading application for a class of ten students. The application should request the names of the students in the class. Students take three exams worth 100 points each in the class. The application should receive the grades for each student and calculate the student’s average exam grade. According to the average, the application should display the student’s name and the letter grade for the class using the grading scheme below. Grading Scheme: •...
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
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this...
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this part of the assignment, you are required to create a C# Console Application project. The project name should be A3<FirstName><LastName>P2. For example, a student with first name John and Last name Smith would name the project A1JohnSmithP2. Write a C# (console) program to calculate the number of shipping labels that can be printed on a sheet of paper. This program will use a menu...
Create an ASP.Net Website using Visual Studio with Visual Basic.Net: Create a simple calculator that has...
Create an ASP.Net Website using Visual Studio with Visual Basic.Net: 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...
use VISUAL STUDIO CODE to write this javascript program Exercise 1 (a) Create a HTML file...
use VISUAL STUDIO CODE to write this javascript program Exercise 1 (a) Create a HTML file that uses createElement and appendChild to dynamically insert three paragraphs when a button is clicked. (b) Create a HTML file that includes JavaScript that is similar to: let recs = [“my item …1”,”my item…2”, …] i.e. an array that contains several CSV item records. When the user clicks a button, each array element will be rendered as a list element. Use a HTML list....
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT