Question: Java Help: This is part 5 of a 5 part question so 5 likes on offer. Part 1: https://www.chegg.com/homework-help/questions-and-answers/java-help-part-1-5-part-multithreading-question-5-likes-offer-part-2-https-wwwcheggcom-hom-q69755166 Part 2: https://www.chegg.com/homework-help/questions-and-answers/java-help-part-2-5-part-question-5-likes-offer-part-1-part-3-part-4-part-5-part-done-2nd-p-q69755173 Part 3: https://www.chegg.com/homework-help/questions-and-answers/java-help-part-3-5-part-question-5-likes-offer-part-1-part-2-part-4-part-5-part-done-3rd-p-q69755184

Java Help: This is part 5 of a 5 part question so 5 likes on offer. Part 1:

https://www.chegg.com/homework-help/questions-and-answers/java-help-part-1-5-part-multithreading-question-5-likes-offer-part-2-https-wwwcheggcom-hom-q69755166

Part 2:

https://www.chegg.com/homework-help/questions-and-answers/java-help-part-2-5-part-question-5-likes-offer-part-1-part-3-part-4-part-5-part-done-2nd-p-q69755173

Part 3:

https://www.chegg.com/homework-help/questions-and-answers/java-help-part-3-5-part-question-5-likes-offer-part-1-part-2-part-4-part-5-part-done-3rd-p-q69755184

Part 4:

https://www.chegg.com/homework-help/questions-and-answers/java-help-part-4-5-part-question-5-likes-offer-part-1-part-2-part-3-part-5-part-done-4th-p-q69755207

This part should be done last. Please use Book.java, Bookstore.java, Buyer.java and Seller.java from prior part solutions.

Part 5: Main.java

This file will contain the main() method that will run your book store simulation. It should create a single instance of the Bookstore class; this instance should be passed into the constructors of any Buyer or Seller objects that are created.

Your main method should simulate a number of days (e.g. 30) at the book store (hint: use e.g. a while loop and repeat the same operations for each day). A message should print to the console announcing the number of books available at the start of each day (see example program output on the last page).

Each day a random number of Buyers (between 0 and e.g. 3) and Sellers (between 0 and e.g. 3) can arrive at the store. For each new Buyer/Seller a new thread must be created and started. You should also add a small delay at the end of each day (loop iteration) to slow down the execution of the program.

Sample (truncated) program output:

Day 1 beginning. There are 0 books in the store today. A new buyer #1 just appeared.

Buyer #1 wants to buy a book, but the store is empty.

A new seller #1 just appeared with a horror book with storecode 11-G-7212 worth 39

to sell.

A new seller #3 just appeared with a thriller book with storecode 18-G-2743 worth 140

to sell.

Seller #1 sold their horror book with storecode 11-G-7212 worth 39 to the store.

This is sale number 1.

A new seller #2 just appeared with a drama book with storecode 18-G-2469 worth 14

to sell.

Buyer #1 bought a horror book with storecode 11-G-7212 worth 39 from the store.

This is purchase number 1.

Seller #3 sold their thriller book with storecode 18-G-2743 worth 140 to the store.

This is sale number 2.

Seller #2 sold their drama book with storecode 18-G-2469 worth 14 to the store.

This is sale number 3.

Day 2 beginning. There are 2 books in the store today.

A new seller #4 just appeared with a thriller book with storecode 18-G-5011 worth 108

to sell.

A new seller #5 just appeared with a thriller book with storecode 15-G-8043 worth 119

to sell.

Seller #4 sold their thriller book with storecode 18-G-5011 worth 108 to the store.

This is sale number 4.

Seller #5 sold their thriller book with storecode 15-G-8043 worth 119 to the store. This is sale number 5.

Day 3 beginning. There are 4 books in the store today.

A new seller #6 just appeared with a fantasy book with storecode 18-G-756 worth 198

to sell.

A new seller #7 just appeared with a thriller book with storecode 16-G-2453 worth 185

to sell.

Seller #6 sold their fantasy book with storecode 18-G-756 worth 198 to the store.

This is sale number 6.

Seller #7 is trying to sell a book, but the store is full. Day 4 beginning. There are 5 books in the store today.

A new buyer #2 just appeared.

A new seller #8 just appeared with a fantasy book with storecode 10-G-5572 worth 114

to sell.

Buyer #2 bought a thriller book with storecode 18-G-2743 worth 140 from the store.

This is purchase number 2.

Seller #7 sold their thriller book with storecode 16-G-2453 worth 185 to the store.

This is sale number 7.

Seller #8 is trying to sell a book, but the store is full. Day 5 beginning. There are 5 books in the store today.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!