Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Examine the code and figure out how to add another button to the GUI. Have this button double the number that the user enters. You

Examine the code and figure out how to add another button to the GUI. Have this button double the number that the user enters. You will have to modify code in multiple files to accomplish this.

Add a fourth button, name it, and wire It to accomplish that function.

Paste a screen shot of your four-action GUI with the correct result from one of your buttons.

Examine the code again, and make modifications that will allow the user to enter two numbers instead of one.

Change the text on the top button to Add and modify the code so that when the user enters two numbers, they will be added together to produce the result.

Change the text on the second button to Subtract and modify the code so that when the user enters two numbers, the second will be subtracted from the first to produce the result.

Change the text on the third button to Multiply and modify the code so that when the user enters two numbers, they will be multiplied to produce the result.

Change the text on the fourth button to Divide and modify the code so that when the user enters two numbers, the first will be divided by the second to produce the result.

Test each button on your GUI, and paste the result window into your Word document. You will have four result windows for this section, one for each of Add, Subtract, Multiply and Divide.

Make sure the code that contains the main method also contains your template. Put a comment at the top of each class that includes your name and the purpose of that class.

**********Java File**************

/* Simple Math Operations Using Buttons

*/

import java.net.URL;

import javafx.application.Application;

import javafx.fxml.FXMLLoader;

import javafx.scene.layout.VBox;

import javafx.scene.Scene;

import javafx.stage.Stage;

public class SimpleMathPractice extends Application

{

@Override

public void start( Stage stage ) // throws Exception

{

try

{

URL url =

getClass( ).getResource( "fxml_simple_math.fxml" );

VBox root = FXMLLoader.load( url );

Scene scene = new Scene( root, 300, 275 );

scene.getStylesheets( ).add( "simple_math.css" );

stage.setTitle( "Simple Math" );

stage.setScene( scene );

stage.show( );

}

catch ( Exception e )

{

e.printStackTrace( );

}

}

public static void main( String [] args )

{

launch( args );

}

}

***********Fxml File************

"1.0" encoding="UTF-8"?>

"SimpleMathController"

xmlns:fx="http://javafx.com/fxml"

alignment="center" spacing="10" >

"operand" maxWidth="100" />

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions