Question
In java write a Java FX app to the following specifications. To avoid problems, just delete the statements that you don't need from the start()
In java 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 VBoxhas 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 Labelshould 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.)
So, if the user enters 10 and 100 in the two TextFields, the output below the Button should look like this. Primes from 10 to 100: 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
Sample runs:
Primes - DX 100 300 Click Primes from 100 to 300: 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229 233 239 241 251 257 263 269 271 277 281 283 293 Primes - O X abc Click - 200 Enter two integers onlyStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started