Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am currently working on a calculator with Scene Builder and Spring Tool Suite and I am currently missing some functions for the following buttons:

I am currently working on a calculator with Scene Builder and Spring Tool Suite and I am currently missing some functions for the following buttons:

Multiplication, division, subtraction, and clear window, could you please show me how to make these buttons work by adding the missing function from below, thanks?

JAVA code:

package application;

import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.TextField;

public class CalController {

double first, second, result;//created to show the first and second number added to the text field and its result. int oper;//this operator was created for plus, minus, division... @FXML private TextField txtField;

@FXML private Button four;

@FXML private Button five;

@FXML private Button plus;

@FXML private Button equal;

@FXML private Button one;

@FXML private Button two;

@FXML private Button three;

@FXML private Button subtraction;

@FXML private Button multiplication;

@FXML private Button division;

@FXML private Button six;

@FXML private Button zero;

@FXML private Button seven;

@FXML private Button eight;

@FXML private Button nine;

@FXML private Button clear;

@FXML void additionFuction(ActionEvent event) { String value= ((Button) event.getSource()).getText(); first= Double.parseDouble(txtField.getText()); txtField.setText(""); }

@FXML void clearWindow(ActionEvent event) {

}

@FXML void divisionFuction(ActionEvent event) { }

@FXML void equalFuction(ActionEvent event) {

second= Double.parseDouble(txtField.getText()); result= first+second; txtField.setText(Double.toString(result)); }

@FXML void handle(ActionEvent event) { String value= ((Button) event.getSource()).getText(); txtField.setText(txtField.getText()+value); }

@FXML void multiplicationFuction(ActionEvent event) {

} @FXML void subtractionFuction(ActionEvent event) { }

}

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

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

Students also viewed these Databases questions

Question

Conduct a needs assessment. page 283

Answered: 1 week ago

Question

Why does sin 2x + cos2x =1 ?

Answered: 1 week ago

Question

What are DNA and RNA and what is the difference between them?

Answered: 1 week ago

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago

Question

2. What are your challenges in the creative process?

Answered: 1 week ago