I’m working on a Java question and need guidance to help me study.
Task 1: Exception Handling
Write a method that accepts two integer prime numbers and returns their product. If either argument is not prime, throw a custom PrimeNumberException and report the number(s) that are not prime. Your custom exception should be a checked exception. In addition to the above, write some code to show how your method works when called with the following arguments:
Two prime numbers
One prime and one non-prime number
Two non-prime numbers
Task 2: File Processing
Write a program that takes a text file name as a runtime argument. If the text file does not exist, print an error message and terminate the program. Otherwise, have your program calculate the number of characters in the file (ignore any white space) and print the result.
Task 3: Rectangles
Write a program that allows a user to create and display rectangle objects. You should write your own Rectangle class for this purpose. Your program should have the following main menu:
## Rectangle Program ##
1. Enter rectangle details
2. Show all rectangles
3. Exit program
If option 1 is selected: Ask the user for a length in centimetres (a float) and a width in centimetres (a float) to create a new rectangle. If the rectangle is successfully created, add it to an ArrayList and report a success message back to the user before re-showing the menu above. If there was an error creating the rectangle (because the user entered non-numeric data or a negative value for the length or width), or if there was an error adding the rectangle to the list, report an appropriate message before re-showing the menu above.
If option 2 is selected: Print out the length, width and area of each rectangle to two decimal places, ordered by area, so that details of the smallest rectangle will be printed first and details of the largest rectangle will be printed last (see example output below). Have your Rectangle class implement the Comparable interface to assist with this task.
Example output for this option:
Length: 2.14cm, Width: 3.57cm, Area: 7.64cm
Length: 3.99cm, Width: 5.11cm, Area: 20.39cm
Length: 5.0cm, Width: 13.4cm, Area: 67.00cm
If option 3 is selected: Terminate the program
Task 4: JavaFX Archery Target
Write a GUI program that displays an archery target within a small window, as per the image below. For the window background use dark sea green; for the archery circles, use white, black, cyan, red and gold. Make sure that your target is centred in the middle of the window, and that the circles are evenly spaced. Design your window so that the user is not able to resize it.