-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassArray.java
More file actions
41 lines (27 loc) · 1.08 KB
/
PassArray.java
File metadata and controls
41 lines (27 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.util.Scanner; //Needed for Scanner Class
/*The program stores in an array hours worked by five employees
* who all make same hourly wage*/
public class PassArray {
public static void main(String[] args) {
final int EMPLOYEES = 5; //number of employees
double payRate;
double grossPay;
//Create an array to hold hours
int[] hours = new int[EMPLOYEES];
Scanner input = new Scanner(System.in);
//Get the hours Worked by Employees
System.out.println("Enter the number of hours worked: ");
for (int i = 0; i < EMPLOYEES; i++) {
hours[i] = input.nextInt();
}
//Get the hourly rate
System.out.println("Enter the hourly Rate: ");
payRate=input.nextDouble();
//Display the results
System.out.println("The gross pay of the Employees are: ");
for (int i = 0; i<EMPLOYEES ; i++) {
grossPay=hours[i]*payRate;
System.out.println("Employees "+(i+1)+" Earn "+grossPay);
}
}
}