Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone please give me the correct solution in Java programming language please (PUICJ. 00/100) The student has to develop FactorialCalculator, a multi-threaded Java program

can someone please give me the correct solution in Java programming language please
image text in transcribed
image text in transcribed
(PUICJ. 00/100) The student has to develop FactorialCalculator, a multi-threaded Java program which computes the factorial of a given number n (n21). The factorial of a positive integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 5! = 1 x 2 x 3 x 4 x 5 = 120. The student has to structure the program according to the following guidelines. Given (in the main program) the integer n (>=1) . the integer numOfThreads (>=1) the multi-threaded Java program computes n! and returns the computed value in output. The task must be performed in concurrency, by splitting the original task in (as balanced as possible) numOfThreads sub-tasks, each one performed by a thread. Implement the code, such that it works for generic values of n and numOfThreads. The output of the program must be generated following the example output reported below (example for n=11 and numofThreads=3): Computation of 11! using 3 threads. Thread-2 [7,11] started... Thread-1 [4,6] started... ... Thread-2 [7,11] completed (Local Factorial: 55440) ...Thread-1 [4,6] completed (Local Factorial: 120) Thread-o [1,3] started... ...Thread-o [1,3] completed (Local Factorial: 6) Final Result: 11! = 39916800 (PUICJ. 00/100) The student has to develop FactorialCalculator, a multi-threaded Java program which computes the factorial of a given number n (n21). The factorial of a positive integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 5! = 1 x 2 x 3 x 4 x 5 = 120. The student has to structure the program according to the following guidelines. Given (in the main program) the integer n (>=1) . the integer numOfThreads (>=1) the multi-threaded Java program computes n! and returns the computed value in output. The task must be performed in concurrency, by splitting the original task in (as balanced as possible) numOfThreads sub-tasks, each one performed by a thread. Implement the code, such that it works for generic values of n and numOfThreads. The output of the program must be generated following the example output reported below (example for n=11 and numofThreads=3): Computation of 11! using 3 threads. Thread-2 [7,11] started... Thread-1 [4,6] started... ... Thread-2 [7,11] completed (Local Factorial: 55440) ...Thread-1 [4,6] completed (Local Factorial: 120) Thread-o [1,3] started... ...Thread-o [1,3] completed (Local Factorial: 6) Final Result: 11! = 39916800

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_2

Step: 3

blur-text-image_3

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

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions