Answered step by step
Verified Expert Solution
Link Copied!

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
image text in transcribed
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions

Question

Question What is a Roth 401(k) feature?

Answered: 1 week ago

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago