MUST USE JAVAFX FOR THIS PROGRAM
Create a application that acts as a simple calculator. Create buttons for 0-9 and a text field that displays the concatenation of the current digits as they are clicked. Add buttons for operators “+”, “-“, “*”, and “/”. Add a final button for “=” that calculates the computed value with the value entered in the text field. For instance, clicking buttons 7, +, 8, = one-by-one, then it should display 15.
SimpleCalculatorFXMLController.java
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
public class SimpleCalculatorFXMLController implements
Initializable {
@FXML private TextField resultField;
@FXML private Button btnOne;
@FXML private Button btnTwo;
@FXML private Button btnThree;
@FXML private Button btnFour;
@FXML private Button btnFive;
@FXML private Button btnSix;
@FXML private Button btnSeven;
@FXML private Button btnEight;
@FXML private Button btnNine;
@FXML private Button btnZero;
@FXML private Button btnEqual;
@FXML private Button btnClear;
@FXML private Button btnAdd;
@FXML private Button btnSub;
@FXML private Button btnMult;
@FXML private Button btnDiv;
private Float data = 0f;
private int operation = -1;
@FXML
private void handleActions(ActionEvent event)
{
if(event.getSource() == btnOne)
{
resultField.setText(resultField.getText() + "1");
}
else if(event.getSource() == btnTwo)
{
resultField.setText(resultField.getText() + "2");
}
else if(event.getSource() == btnThree)
{
resultField.setText(resultField.getText() + "3");
}
else if(event.getSource() == btnFour)
{
resultField.setText(resultField.getText() + "4");
}
else if(event.getSource() == btnFive)
{
resultField.setText(resultField.getText() + "5");
}
else if(event.getSource() == btnSix)
{
resultField.setText(resultField.getText() + "6");
}
else if(event.getSource() == btnSeven)
{
resultField.setText(resultField.getText() + "7");
}
else if(event.getSource() == btnEight)
{
resultField.setText(resultField.getText() + "8");
}
else if(event.getSource() == btnNine)
{
resultField.setText(resultField.getText() + "9");
}
else if(event.getSource() == btnZero)
{
resultField.setText(resultField.getText() + "0");
}
else if(event.getSource() == btnClear)
{
resultField.setText("");
}
else if(event.getSource() == btnAdd)
{
data = Float.parseFloat(resultField.getText());
operation = 1; // Add
resultField.setText("");
}
else if(event.getSource() == btnSub)
{
data = Float.parseFloat(resultField.getText());
operation = 2; // Subtract
resultField.setText("");
}
else if(event.getSource() == btnMult)
{
data = Float.parseFloat(resultField.getText());
operation = 3; // Multiply
resultField.setText("");
}
else if(event.getSource() == btnDiv)
{
data = Float.parseFloat(resultField.getText());
operation = 4; // Divide
resultField.setText("");
}
else if(event.getSource() == btnEqual)
{
Float secondNumber = Float.parseFloat(resultField.getText());
switch(operation)
{
case 1:
Float sum = data + secondNumber;
resultField.setText(String.valueOf(sum));
break;
case 2:
Float diff = data - secondNumber;
resultField.setText(String.valueOf(diff));
break;
case 3:
Float prod = data * secondNumber;
resultField.setText(String.valueOf(prod));
break;
case 4:
Float quot = 0f;
try
{
quot = data / secondNumber;
}catch(Exception e){
resultField.setText("Error!");
}
resultField.setText(String.valueOf(quot));
break;
}
}
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
SimpleCalculatorFXML.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<AnchorPane id="AnchorPane" prefHeight="256.0"
prefWidth="267.0" xmlns:fx="http://javafx.com/fxml/1"
xmlns="http://javafx.com/javafx/8.0.171"
fx:controller="simplecalculator.SimpleCalculatorFXMLController">
<children>
<TextField fx:id="resultField" layoutX="12.0" layoutY="14.0"
prefHeight="36.0" prefWidth="241.0" />
<Button fx:id="btnOne" layoutX="14.0" layoutY="66.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="1">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnTwo" layoutX="76.0" layoutY="66.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="2">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnThree" layoutX="138.0" layoutY="66.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="3">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnFour" layoutX="14.0" layoutY="113.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="4">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnFive" layoutX="76.0" layoutY="113.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="5">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnSix" layoutX="138.0" layoutY="113.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="6">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnSeven" layoutX="12.0" layoutY="159.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="7">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnEight" layoutX="74.0" layoutY="159.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="8">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnNine" layoutX="136.0" layoutY="159.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="9">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnZero" layoutX="12.0" layoutY="204.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="0">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnEqual" layoutX="74.0" layoutY="204.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="=">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnClear" layoutX="136.0" layoutY="204.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="CL">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnAdd" layoutX="201.0" layoutY="68.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="+">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnSub" layoutX="201.0" layoutY="115.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="-">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnMult" layoutX="199.0" layoutY="161.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="*">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
<Button fx:id="btnDiv" layoutX="199.0" layoutY="206.0"
mnemonicParsing="false" onAction="#handleActions" prefHeight="36.0"
prefWidth="52.0" text="/">
<font>
<Font name="System Bold" size="15.0" />
</font>
</Button>
</children>
</AnchorPane>
SimpleCalculator.java (Main class)
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class SimpleCalculator extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root =
FXMLLoader.load(getClass().getResource("SimpleCalculatorFXML.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setTitle("Simple Calculator");
stage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
****************************************************************** SCREENSHOT *********************************************************



MUST USE JAVAFX FOR THIS PROGRAM Create a application that acts as a simple calculator. Create buttons...
Using Java, please create the program for the following prompt.
MUST CREATE BUTTONS IN A JFRAME, as specified by the prompt! DO NOT
use user input of 1, 2, 3 etc. User input must come from clicking
the buttons. Please be sure to test your program. Thank you!
Write a program that displays three buttons with the names or images of three candidates for public of office. Imagine that a person votes by clicking the button that shows the candidate...
Create a GUI or JavaFX application with two buttons and two labels. Add an Image Icon of your choice to the first button and the first label.
Tip Calculator App & Order Using NetBeans create a new JavaFX project with two classes TipCalculator (the JavaFX class) and Order Create the Tip Calculator as follows: Start with an Order class with two instance variables, item a String and price a double; include two constructors, a no-parameter constructor that passes default values empty String and zero (0) to the second constructor which then calls the set methods for item and price; the set method for price validates that price...
For this question you will need to complete the methods to create a JavaFX GUI application that implements two String analysis algorithms. Each algorithm is activated when its associated button is pressed. They both take their input from the text typed by the user in a TextField and they both display their output via a Text component at the bottom of the GUI, which is initialized to “Choose a string methods as indicated in the partially completed class shown after...
in JAVA please and please show output!!
Create a JavaFX application that simulates the rolling of a pair of
dice. When the user clicks a button, the application should
generate two random numbers, each in the range of 1 through 6, to
represent the value of the dice. Use ImageView component to display
the dice. Six images are included in the project folder for you to
use. For example, the first picture below is the initial window,
after clicking the...
(java)write a simple graphical calculator with four operations: addition,substractuon, multipication division, that must do the following: a)it must support real and whole numbers (3.5 and 3 for instance).. b)it must support negative numbers using a button "+/-" that allows changing between positivity and negativity of the number c)the graphical interface of the calculator will include a matrix of buttons that include the digits 0,...,9 and "+" "-""*" "/" "." "+/-" and "=". d)the calculator will include a text field that...
I. User Interface Create a JavaFX application with a graphical user interface (GUI) based on the attached “GUI Mock-Up”. Write code to display each of the following screens in the GUI: A. A main screen, showing the following controls: • buttons for “Add”, “Modify”, “Delete”, “Search” for parts and products, and “Exit” • lists for parts and products • text boxes for searching for parts and products • title labels for parts, products, and the application title B. An add...
Please help me do this program.
Add some comments on it.
*15.5 (Create an investment-value calculator) Write a program that calculates the future value of an investment at a for the calculation is given interest rate for a specified number of years. The formula investmentAmount * (1monthlyInterestRate ) years *12 futureValue Use text fields for the investment amount, number of years, and annual interest rate. Display the future amount in a text field when the user clicks the Calculate button,...
Create a windows form application in c# The form must look like a calculator and do the following. Add, subtract, multiply, and divide. Account for division by zero. Show at least two decimal places. Retain the last number on the window so that, when the user opens the calculator the next time, the number that was in the window at the last close appears. Have a memory, so that users can store values and recall them. Operate with a mouse...
JAVAFX PROGRAM
Write a program that will allow two users to play a game of tic-tac-toe. The game area should consist of nine buttons for the play area, a reset button, and a label that will display the current player's turn. When the program starts, the game area buttons should have no values in them (i.e. they should be blank) When player one clicks on a game area button, the button should get the value X. When player two clicks...