In either BlueJ or NetBeans, create a new project and complete one of the following assignments:
- The "greatest common divisor" for two numbers is the highest number by which both can be divided evenly;
- For example the greatest common divisor for the two numbers 42 and 18 is 6, e.g.
42 ÷ 6 = 7
and18 ÷ 6 = 3
- Create a "GreatestCommonDivisor.java" class file with two methods,
gcd()
andmain()
- In method
main()
get the value to pass togcd()
from either aScanner
object orshowInputDialog()
; display the return value of the recursive method to either the terminal window or ashowMessageDialog()
window- The
main()
method should includetry...catch
exception handling forInputMismatchException
orNumberFormatException
, and for a programmer-generatedException
that is thrown for negative values for either of the two inputs from the user
- Create a "FractionSum.java" class file with two methods,
sum()
andmain()
- Although the textbook specifies displaying the values of m(i) for 1, 2, ..., 10, rather display only a single result for a user input value for i
- In method
main()
get the value to pass tosum()
from either aScanner
object orshowInputDialog()
; display the return value of the recursive method to either the terminal window or ashowMessageDialog()
window- For example if the user inputs the value 4 for i, the recursive
sum()
method will calculate:1 + ½ + ⅓ + ¼ = 2.083
(rounded to three decimals)- The
main()
method should includetry...catch
exception handling forInputMismatchException
orNumberFormatException
, and for a programmer-generatedException
that is thrown for negative value input from the user
- Create a "ReverseString.java" class file with two methods,
reverseDisplay()
andmain()
- The method
reverseDisplay()
has a return value (not as specified in the textbook); the correct header should be:
private static String reverseDisplay(String value)
- In method
main()
get the string to pass toreverseDisplay()
from either aScanner
object orshowInputDialog()
; display the return value of the recursive method to either the terminal window or ashowMessageDialog()
window- The
main()
method should includetry...catch
exception handling for a programmer-generatedException
that is thrown for empty string input from the user
- Create an "CreateMaze.java class file as a JavaFX application
- Write a recursive method that is called from the CreateMaze constructor that solves the "Create a maze" problem and displays the maze and the correct path to traverse the maze
- Although not stated in the textbook, the purpose of the "Clear Path" button is to clear the gray colored path solution squares so that the user can click the "Find Path" button again to see if the "Create a maze" algorithm will find an alternative solution
- Including a substantive comment statement that describes the class's purpose, as well as substituting your name for the existing @author comment and the assignment due date for the @version comment that already exist at the top of each new class
- Entering a substantive comment before each method (including the any constructors) to describe its function along with @parameter, @throws and @return tags