Question: For this assignment, you are to write a JavaFX program that does the following: Creates a GUI with a label and associated text field. The

For this assignment, you are to write a JavaFX program that does the following:
Creates a GUI with a label and associated text field.
The label field should contain the text Number:
In the text field, a user will enter a number. Your program should display an error message in the text field described in 2) if the user does not input a valid number (which is an integer that is greater than or equal to zero).
The GUI should also have a text field to output. After the Process Input button (see below) is selected, the program will determine if the number input in the text field in 1) is prime or not. If it is prime, this text field should be updated to state the input number and the text is prime or is not prime as appropriate. For example, for the number 3 it would produce: 3 is prime and for the number 4 it would produce 4 is not prime.
Important: Dont worry about doing sophisticated methods to determine if a number is prime or to generate the prime factors. A brute force method is ok. Note the definition of a prime number: A Prime number is prime if it is only evenly divisible by 1 or itself. Also note that 1 is not a prime number.
You GUI needs to include Process Input and Cancel buttons, and the text on these buttons must be as indicated here (Process Input, Cancel) When Process Input is pressed, the program should read the text in 1), do the prime number determination, and update the output text field (2) with the appropriate text. When cancel is pressed, your program should gracefully terminate.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!