Using Java Task 1) Write a class, named Counter, that prints numbers 0 to 9 on a single line and skips to the next line. Task 2) Repeat that an indefinite number of times until the user sets a flag done as 'false'. Task 3) Run the Counter repeatedly until the user wants to set the flag as 'false'. Task 4) Develop a simple GUI with a STOP button that will stop the Counter class from printing the numbers indefinitely. In other words, you will automatically start the Counter class, and the STOP button will stop its execution.
Using Java
Task 1) Write a class, named Counter, that prints numbers 0 to 9 on a single line and skips to the next line.
Task 2) Repeat that an indefinite number of times until the user sets a flag done as 'false'.
Task 3) Run the Counter repeatedly until the user wants to set the flag as 'false'.
Task 4) Develop a simple GUI with a STOP button that will stop the Counter class from printing the numbers indefinitely. In other words, you will automatically start the Counter class, and the STOP button will stop its execution.
Task 5) Add a START button to your GUI that will start the Counter. STOP button will still pause the counter. You should be able to start the Counter again by pressing the START button.
Task 6) Write a similar class Counter2 that will print numbers in the reverse order, 9 to 0, and skip to the next line.
Run both counters on different threads, START and STOP buttons should control both of the counters together.
Run your application, and observe how responsive are the buttons in controlling the printing
share the screenshot of your code.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps