+ 1

maximum wage, minimum wage and average of all wages

how do i make my program to be able to calculate maximum wage, minimum wage and average of all wages? https://code.sololearn.com/c5h29RCDmM91/?ref=app

24th Sep 2021, 12:44 PM
Bobby Dike
Bobby Dike - avatar
10 Respuestas
+ 2
You don't. Common way for traversing an array is by using for...loop.
24th Sep 2021, 1:17 PM
Ipang
+ 2
I'll be back later, I have to go again now. Please try to make that Employee class, so we can move on later ...
24th Sep 2021, 1:28 PM
Ipang
+ 2
Ipang I suggested and wrote class Employee before, you can use it https://www.sololearn.com/Discuss/2887429/?ref=app https://www.sololearn.com/Discuss/2888137/?ref=app
24th Sep 2021, 2:30 PM
zemiak
+ 2
Zemiak, Sorry about that, I forget a lot of things. I didn't even check his questions to notice ... #unsub
24th Sep 2021, 2:34 PM
Ipang
+ 2
Ipang I have already given solution as you explained in 1st reply. I think it is easy to do that. Bobby Dike You can use Java stream API to get min and max wages. I have done both things in my code. Now to get average you can get sum of all wages using Java Stream and after getting sum divide sum with length of employee list. Or you can use average method of stream class https://code.sololearn.com/cfXzaLDTMoCe/?ref=app
24th Sep 2021, 3:40 PM
A͢J
A͢J - avatar
+ 2
Yes AJ, My bad I didn't check he had posted it earlier.
24th Sep 2021, 3:51 PM
Ipang
+ 1
I would create an Employee class and fill it with id, name, workHours etc. properties. Then I can create an array (or ArayList) of Employee class to contain the records. Next I would traverse the array to find the min & max wages, sum the wages and divide the result with number of array's elements to get the average.
24th Sep 2021, 1:14 PM
Ipang
0
how do i traverse the array using the if statement
24th Sep 2021, 1:15 PM
Bobby Dike
Bobby Dike - avatar
0
okay, how do i write the statement. I've tried but there are too many errors. its in the program i posted
24th Sep 2021, 1:25 PM
Bobby Dike
Bobby Dike - avatar