Question: Write a Java FX app to the following specifications. To avoid problems, just delete the statements that you don't need from the start() method of
Write a Java FX app to the following specifications. To avoid problems, just delete the statements that you don't need from the start() method of the HappyFace app and enter your own code.
The interface has a scene whose root element is a VBox (400 by 200 pixels is a good size). The VBox has two TextField objects in an HBox object, with "10" as the text in one and "100" as the text in the other, followed by a Button that says "Find primes between those numbers", followed by a Label that says "Answer will appear here. ".
To decide if a number is prime, write an isPrime(int n) method. In the body of the method, set a boolean variable prime to true, then loop from 2 to the square root of n, inclusive, and, if n is divisible by the loop counter, set prime to false. After the loop, return prime.
When the Button is clicked, the Text of the Label should be changed to output all of the prime numbers between the numbers in the two TextFields (if there is a NumberFormatException, set the Label text to "Enter two integers only!" and return), in a format like the following (use tabs after each number, count the number of primes that have been output, and when that number is greater than 10, output a newline and reset the number to 0.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
