Students kindly share assignment files in relevant subject timely for discussion/solution.
or directly share with us " Click here"
[Solved] CS508 Assignment 3 Spring 2020
CS508 Modern Programming Languages Assignment 3 Solution & Discussion Spring 2020
Assignment No. 03
CS508- Modern Programming Languages
Total Marks: 20
Due Date: July 27, 2020
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit if:
· The assignment is submitted after due date.
· The submitted assignment does not open or file is corrupt.
· The assignment is completely or partially copied from (other student or ditto copied from handouts or internet).
· Student ID is not mentioned in the assignment File or name of file is other than student ID.
· The assignment is not submitted in .rar format.
If you do not submit any of the above mentioned file 50% marks per file will be deducted.
The objective of this assignment is to give students an idea on how to implement Multithreading with Synchronization concepts in JAVA.
Lectures Covered: This assignment covers Lecture # 27-30
You are required to create a multithreaded console application in java having 4 classes which will calculate factorial of last 4 digits of your student id. These classes would be as follow:
1. Main class
2. Factorial Class having one method which will calculate factorial named printfactorial().
3. Thread1 class which extends from Thread Class
4. Thread2 class which also extends from Thread Class
Store last four digits of your student ID in a two separate classes. For example, if your ID is bc123456789 then store 67 in first Thread1 Class and 89 in Thread2 Class that will be passed to Factorial class later.
Thread1 class will pass 67 to the Factorial class and printfactorial() will print factorial of all the numbers from 1 to 67.
Thread2 class will pass 89to the Factorial class and printfactorial() will print factorial of all the numbers from 1 to 89.
You should use thread.sleep(10) after each calculation inside the loop.
As you know that you cannot store and print factorial of large numbers in simple integer or long type variables, so you are required to use BigInteger to store and print very long numbers.
printfactorial() method must be synchronized so that results of Thread1 is printed first then the result of Thread2 is calculated and printed.
Note: Proper exception handling code must be written where required.