-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHourlySalaryTest.java
More file actions
53 lines (45 loc) · 1.8 KB
/
HourlySalaryTest.java
File metadata and controls
53 lines (45 loc) · 1.8 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
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Programmer: Dan Hopp
* Date: 20-NOV-2019
* Description:
• Take user input for the hourly salaries of 10 employees.
• Use the methods defined in the Salary class to print the hourly salary
of all employees, average salary, highest salary, lowest salary, and the
number of employees with the below-average salary.
*/
package lab8;
import java.util.Scanner;
public class HourlySalaryTest {
public static void main(String[] args) {
//create array
double[] salaries = new double[10];
//create class instance
HourlySalary hs = new HourlySalary();
//Take user input for the hourly salaries of 10 employees
Scanner input = new Scanner(System.in);
System.out.print("Please enter 10 hourly salaries: ");
for(int i = 0; i < salaries.length; i++){
salaries[i] = input.nextDouble();
}
//blank line
System.out.println();
//Use the methods defined in the Salary class:
//print the hourly salary of all employees
HourlySalary.printSalary(salaries);
//blank line
System.out.println();
//print average salary
double salaryAverage = hs.averageSalary(salaries);
System.out.printf("The average hourly salary is $%4.2f.\n",
salaryAverage);
//print highest salary
hs.highestSalary(salaries);
//print lowest salary
hs.lowestSalary(salaries);
//print number of employees with below-average salary
System.out.println("The number of employees with less than the average" +
" hourly salary is " +
hs.belowAverageSalary(salaries, salaryAverage) +
".");
}
}