Question

Write a program which: Write a program which uses the following arrays: empID: An array of...

Write a program which: Write a program which uses the following arrays:

empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7.

Hours: an array of seven integers to hold the number of hours worked by each employee.

payRate: an array of seven doubles to hold each employee’s hourly pay rate.

Wages: an array of seven doubles to hold each employee’s gross salary.

The program should display each employee number and ask the user to enter that employee’s hours and pay rate. It should then calculate the gross wages for that employee (hours times pay rate) and store them in the wages array. After the data has been entered for all the employees, the program should display each employee’s identification number and gross wages.

General Restrictions : No global variables No labels or go-to statements No infinite loops, examples include: for(;;) while(1) while(true) do{//code}while(1); No break statements to exit loops.

Homework Answers

Answer #1

import java.util.Scanner;

public class WagesCalculator {

    public static void main(String[] args) {
        int empID[] = {1, 2, 3, 4, 5, 6, 7};
        
        int hours[] = new int[7];
        double payRate[] = new double[7];
        double wages[] = new double[7];
        
        Scanner reader = new Scanner(System.in);

        for(int i=0; i<empID.length; i++) {
            System.out.println("Employee ID: " + empID[i]);
            System.out.println("Enter the hours for employee: ");
            hours[i] = reader.nextInt();
            System.out.println("Enter the pay rate for employee: ");
            payRate[i] = reader.nextInt();
            
            wages[i] = hours[i] * payRate[i];
        }

        System.out.println("\n\nSalary details:");
        for(int i=0; i<empID.length; i++) {
            System.out.println("Employee ID: " + empID[i] + ", Gross wages: $" + wages[i]);
        }
        
        reader.close();
    }

}

**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a program that uses an array of integers initialized to whatever values you wish. Write...
Write a program that uses an array of integers initialized to whatever values you wish. Write a methods to calculate and return the minimum and a method to calculate and return the maximum value in the array. Write an additional method that accepts the array as a parameter and then creates and returns a new array with all the same values as the original plus 10. (num +=10) In Java
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
(Use C++ language) Create a program, named threeTypesLoops.cpp, that does the following; 1. Uses a For...
(Use C++ language) Create a program, named threeTypesLoops.cpp, that does the following; 1. Uses a For Loop that asks for a number between 1 and 10; Will double the number each time through the loop and display the answer. Will run five times, so the number will have been doubled five times, and the answer displayed five times. After the loop, display a message saying 'It's done!'. 2. Uses a While Loop; Ask the user to input a friend's name....
Create a C# application You are to create a class object called “Employee” which included eight...
Create a C# application You are to create a class object called “Employee” which included eight private variables: firstN lastN dNum wage: holds how much the person makes per hour weekHrsWkd: holds how many total hours the person worked each week. regHrsAmt: initialize to a fixed amount of 40 using constructor. regPay otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods:  constructor  properties  CalcPay(): Calculate the regular...
Write a program that allows two players to play a game of tic-tac-toe. Use a twodimensional...
Write a program that allows two players to play a game of tic-tac-toe. Use a twodimensional char array with three rows and three columns as the game board. Each element in the array should be initialized with an asterisk (*). The program should run a loop that: • Displays the contents of the board array. • Allows player 1 to select a location on the board for an X. The program should ask the user to enter the row and...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter...
x86 irvine library assembly code Write a complete program that: 1. Prompt the user to enter 10 numbers. 2. save those numbers in a 32-bit integer array. 3. Print the array with the same order it was entered. 3. Calculate the sum of the numbers and display it. 4. Calculate the mean of the array and display it. 5. Rotate the members in the array forward one position for 9 times. so the last rotation will display the array in...
Write the following program in MIPS: a) declare an array A of the following numbers: 3,...
Write the following program in MIPS: a) declare an array A of the following numbers: 3, 5, 8, 10, 12, 2, 76, 43, 90, 44 b) declare a variable called size which stores the number of element in array A, that is 10. c) write a subroutine to search for a number stored in an array and return true or false. In C++ the subroutine is as follows: search(array, size, number_To_Search) e.g. search(A, 10, 12) The subroutine should return 0...
Write an application in Java which includes an algorithm that takes an array of any size,...
Write an application in Java which includes an algorithm that takes an array of any size, selects the high and low integer from the array of integers with each pass and builds a new array of integers by inserting the high and low selection with each pass. Your output should show the original array of integers and the output of each pass on a new line. Note: You can assume all integers are positive, but your code must work for...
This program is in C++: Write a program to allow the user to: 1. Create two...
This program is in C++: Write a program to allow the user to: 1. Create two classes. Employee and Departments. The Department class will have: DepartmentID, Departmentname, DepartmentHeadName. The Employee class will have employeeID, emploeename, employeesalary, employeeage, employeeDepartmentID. Both of the above classes should have appropriate constructors, accessor methods. 2. Create two arrays . One for Employee with the size 5 and another one for Department with the size 3. Your program should display a menu for the user to...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT