Question: Write a Java code (using JavaFX) which displays a window identical to the one shown in the figure below. The window contains two text fields
Write a Java code (using JavaFX) which displays a window identical to the one shown in the figure below. The window contains two text fields (first number, second number) and a text area (Result). It also has 5 buttons (Add, Subtract, Multiply, Divide, and Clear). The window simulates a calculator. The user enters numbers (might have a decimal point) in the first two text fields (first number and second number) and then clicks on the operation button that he wants to apply. The result should be displayed in the text area field (Result). The clear button returns the values of all the text fields and text area to their default values (the default value for all text fields is an empty string). Keep in mind the following notes: a. Use GridPane class for the layout of GUI components. b. For the division operator, you have to check if the second argument is NOT zero (you cant divide by zero). If the second field is zero, do not apply the division operation. Show an Alert error message to the user that a division by zero is not allowed. c. When the user presses on arithmetic operation button, the result of the operation should be appended (concatenated) to the current result in the text area (not replacing it)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
