Write a multi-threaded program, Stats.java, in Java that calculates various statistical values for a list of numbers.
Fantastic news! We've Found the answer you've been seeking!
Question:
Write a multi-threaded program, Stats.java, in Java that calculates various statistical values for a list of numbers. This program (think of it as the "parent" thread) will prompt the user to provide a single line of input consisting of a series of whitespace-separated numbers and then print the average, maximum, and minimum values entered. For example, suppose your program is passed the integers
90 81 78 95 79 72 85
The program will report (in this order):
The average value is 82
The minimum value is 72
The maximum value is 95
Restrictions:
- Your program must not make any assumptions as to how many numbers the user will enter
- Your program MUST use three separate worker threads to calculate the output values: one will determine the average of the numbers, the second will determine the maximum value, and the third will determine the minimum value
- The values must be output in the specified order every time the program is run
- The calculations must occur concurrently, as much as possible, to allow the program to complete as quickly as possible
Related Book For
Posted Date: