Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NB: all the questions on this assessment are based on both learning unit 9: Threads and learning unit 10: Concurrency Application Question(s) 25 Marks

NB: all the questions on this assessment are based on both learning unit 9: Threads and learning unit 10:Scenario Question(s) Question 2 Study the scenario and complete the question(s) that follow CTU Sports DayMarking Rubric Description Question 1 Made use of a synchronized object Made use of an atomic integer object

NB: all the questions on this assessment are based on both learning unit 9: Threads and learning unit 10: Concurrency Application Question(s) 25 Marks Question 1 Create a Java program that simulates a basic counter. The counter should be incremented by multiple threads. Two (2) threads per implementation. Implementations: 1. Use synchronized keyword to increment the counter and to display the value of the counter. 2 Use Atomic Integer from java.util.concurrent.atomic package to increment the counter and display its value Ensure that the value of the counter is correctly displayed when incremented by multiple threads in both implementations Expected Output: The output can vary because of thread interleaving, but the final count value must be consistent. For example, if you have two threads and each one increments the counter 1000 times, the final counter value should be 2000. Design an interface that will prompt the user to insert a value that will be incremented using both threads Below is an example of the interface where each thread increments the counter 5 times. ENTER VALUE COUNT RESULT 10 NB: your interface must prompt the user for both implementations. PRG522-Formative Assessment 3 Semester 2 Paper 2023 (V10 INPUT BUTTON OUTPUT Page 3 of 5 Scenario Question(s) Question 2 Study the scenario and complete the question(s) that follow CTU Sports Day Timer App Faced with the challenge of implementing a high-performance stop-watch feature in an athletic performance tracking application, Sarah, a seasoned Java developer, dives into her IDE with focus and determination. The requirements specify that the stop-watch must be accurate down to the second and must allow users to start, and stop the time via a user-friendly interface. After carefully weighing her options, she decides to utilize Java's System.current TimeMillis() method for precise time tracking, as well as threading to ensure that the stop-watch runs independently of the application's main execution flow. Armed with her plan, she crafts a robust class encapsulating the stop-watch logic. complete with methods for start, and stop. With a solid test suite validating the accuracy and performance of her implementation, Sarah confidently merges her code into the main branch, enhancing the application's functionality and meeting the needs of athletes striving for peak performance. Source: Mashile T. (2023) Create a Java application for CTU Sports Day called "CTU Timer". The application must consist of a graphic user interface similar to the one displayed below: CTU TIMER TIME in seconds) START TIMER STOP TIMER uneditable text field buttons 25 Marks It must consist of two (2) buttons, labels and an uneditable text field to display the counts. The application must make use of a thread to do the counting. The counter should move at intervals of one (1) second. When the Start timer button is clicked, the timer should start counting. When the Stop timer button is clicked, the timer should stop When the "Start timer button is clicked again, the timer must continue counting where it left off Instructions to submit: Create a folder in which you will compress and submit your work This folder should contain two (2) documents NB: If you develop a basic Java Swing app that simply implements a timer but does not use threads you will get extensive mark deductions. Ensure that your application handles basic exceptions 1 A text file which contains the source code 2 A PDF file which shows screenshots of your source code and interface in a sequential manner of execution of your applications both in Question 1 and Question 2 End of Formative Assessment 2 Grand Total: 50 Marking Rubric Description Question 1 Made use of a synchronized object Made use of an atomic integer object Created two Synchronized threads Created two Atomic Integer threads Designed appropriate user interfaces Question 2 Start/Stop button works The timer counter stops and continues from where it stopped Made use of appropriate methods: Start), Stopo, Try Catch Good programming practices: Comments, Classes, Objects, Indentation, Line spacing, and Inheritance Made use of a thread for the counter Designed an appropriate user interface Good PRG522 - Formative Assessment 3 Semester 2 Paper 2023 | V10 Marking Criteria Farly good Question 1 Total Question 2 Total Final mark /25 /25 /50 Page 5 of 5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Solutions Step 1 Answer 1 Here is the Java program for the first GUI task to display the counter import javafxapplicationApplicationimport javafxsceneSceneimport javafxscenecontrolButtonimport javafxs... 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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions