Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE SOLVE Questionl (50 points) Using JAVA Threads and the Join method: We need to write a Java program that allows us to calculate the
PLEASE SOLVE
Questionl (50 points) Using JAVA Threads and the Join method: We need to write a Java program that allows us to calculate the average price of items in a shop. The program will create two Threads as follows: 1. Main thread a. Asks the user to enter the price of 3 items, and store these prices in an array (double not integer) b. Creates, starts and synchronizes the necessary threads c. Displays the number of prices above the average and the number of prices below the average (using the DataCalculator Thread) 2. DataCalculator Thread The thread receives three parameters. The first parameter is a reference to an array of double values. The second parameter is a double value called "num The third parameter is a Boolean called "isAbove" If isAbove is true the thread will calculate the number of values in the array that are greater than num. Otherwise, the thread calculates the number of values that are below num Notes 1 You should use the join method to synchronize the threads (Do not use semaphore 2 it is your responsibility to know when to use the join method to get correct results in the fastest way Sample Run The underlined values are entered by the user Enter prices 89 90 70 60 SO Number of prices above average Number of prices belowakerage Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started