Question
Can't someone help me with this java code? I tryna add more operator such as minus, multiple and divide but I can not . plz
Can't someone help me with this java code? I tryna add more operator such as minus, multiple and divide but I can not .
plz help me with this one.
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; int oper;
@FXML private TextField txtfield;
@FXML private Button one;
@FXML private Button two;
@FXML private Button three;
@FXML private Button four;
@FXML private Button five;
@FXML private Button six;
@FXML private Button seven;
@FXML private Button eight;
@FXML private Button nine;
@FXML private Button zero;
@FXML private Button plus;
@FXML private Button equal;
@FXML private Button multiple;
@FXML private Button minus;
@FXML private Button divide;
///////////////////////////////////////////////////////////////////////////// @FXML void handle(ActionEvent event) { String value=((Button)event.getSource()).getText(); txtfield.setText(txtfield.getText()+value); } @FXML void equalfunction(ActionEvent event) { //plus// second= Double.parseDouble(txtfield.getText()); result= first + second; txtfield.setText(Double.toString(result)); } @FXML void plusfunction(ActionEvent event) { String value = ((Button)event.getSource()).getText(); first = Double.parseDouble(txtfield.getText()); txtfield.setText(""); }
@FXML void minusfunction(ActionEvent event) {
}
@FXML void multiplefunction(ActionEvent event) {
}
@FXML void dividefunction(ActionEvent event) { }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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