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.
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.
Get Answers For Free
Most questions answered within 1 hours.