diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/libraries/javafx_sdk_19.xml b/.idea/libraries/javafx_sdk_19.xml
new file mode 100644
index 0000000..b16aa79
--- /dev/null
+++ b/.idea/libraries/javafx_sdk_19.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
new file mode 100644
index 0000000..eb3bb1a
--- /dev/null
+++ b/.idea/libraries/lib.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..f2f5415
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..e2c12dd
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Calculator-JavaFX.iml b/Calculator-JavaFX.iml
new file mode 100644
index 0000000..a722889
--- /dev/null
+++ b/Calculator-JavaFX.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/production/Calculator-JavaFX/calculatorjavafx/CalculatorJavaFx.class b/out/production/Calculator-JavaFX/calculatorjavafx/CalculatorJavaFx.class
new file mode 100644
index 0000000..17756ef
Binary files /dev/null and b/out/production/Calculator-JavaFX/calculatorjavafx/CalculatorJavaFx.class differ
diff --git a/out/production/Calculator-JavaFX/calculatorjavafx/FXMLDocument.fxml b/out/production/Calculator-JavaFX/calculatorjavafx/FXMLDocument.fxml
new file mode 100644
index 0000000..73e4728
--- /dev/null
+++ b/out/production/Calculator-JavaFX/calculatorjavafx/FXMLDocument.fxml
@@ -0,0 +1,340 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/out/production/Calculator-JavaFX/calculatorjavafx/FXMLDocumentController.class b/out/production/Calculator-JavaFX/calculatorjavafx/FXMLDocumentController.class
new file mode 100644
index 0000000..5073a31
Binary files /dev/null and b/out/production/Calculator-JavaFX/calculatorjavafx/FXMLDocumentController.class differ
diff --git a/out/production/Calculator-JavaFX/calculatorjavafx/JavaFxCalculator.png b/out/production/Calculator-JavaFX/calculatorjavafx/JavaFxCalculator.png
new file mode 100644
index 0000000..924bd51
Binary files /dev/null and b/out/production/Calculator-JavaFX/calculatorjavafx/JavaFxCalculator.png differ
diff --git a/out/production/Calculator-JavaFX/calculatorjavafx/style.css b/out/production/Calculator-JavaFX/calculatorjavafx/style.css
new file mode 100644
index 0000000..6e717d7
--- /dev/null
+++ b/out/production/Calculator-JavaFX/calculatorjavafx/style.css
@@ -0,0 +1,30 @@
+/*
+To change this license header, choose License Headers in Project Properties.
+To change this template file, choose Tools | Templates
+and open the template in the editor.
+*/
+/*
+ Created on : 15 Aug, 2017, 5:39:25 PM
+ Author : mrunal
+*/
+.button{
+ -fx-background-color: #2d2d2d;
+ -fx-border-color: black;
+
+}
+
+.button:hover{
+
+ -fx-text-fill: white ;
+}
+
+#tf{
+ -fx-background-color: #080101;
+ -fx-text-fill : white;
+}
+#tf2{
+ -fx-background-color: #080101;
+ -fx-text-fill: whitesmoke;
+}
+
+
diff --git a/src/calculatorjavafx/FXMLDocument.fxml b/src/calculatorjavafx/FXMLDocument.fxml
index 5ae8334..73e4728 100644
--- a/src/calculatorjavafx/FXMLDocument.fxml
+++ b/src/calculatorjavafx/FXMLDocument.fxml
@@ -7,248 +7,334 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
diff --git a/src/calculatorjavafx/FXMLDocumentController.java b/src/calculatorjavafx/FXMLDocumentController.java
index 62cc734..eba8276 100644
--- a/src/calculatorjavafx/FXMLDocumentController.java
+++ b/src/calculatorjavafx/FXMLDocumentController.java
@@ -1,36 +1,29 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
package calculatorjavafx;
-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.Labeled;
import javafx.scene.control.TextField;
+import java.lang.Math;
+
+import java.net.URL;
+import java.util.ResourceBundle;
-/**
- *
- * @author mrunal
- */
public class FXMLDocumentController implements Initializable {
-
+
@FXML
- private TextField tf,tf2 ;
-
+ private Button clear;
+
@FXML
- private Button two;
+ private Button division;
@FXML
- private Button three;
+ private Button eight;
@FXML
- private Button six;
+ private Button equals;
@FXML
private Button five;
@@ -39,41 +32,57 @@ public class FXMLDocumentController implements Initializable {
private Button four;
@FXML
- private Button seven;
+ private Button fraction;
@FXML
- private Button eight;
+ private Button minus;
@FXML
- private Button nine;
+ private Button mult;
@FXML
- private Button equals;
+ private Button negative;
@FXML
- private Button zero;
+ private Button nine;
@FXML
- private Button clear;
+ private Button one;
@FXML
private Button plus;
@FXML
- private Button mult;
+ private Button seven;
@FXML
- private Button minus;
+ private Button six;
@FXML
- private Button one;
-
+ private Button square;
+
@FXML
- private Button division;
-
+ private Button squareRoot;
+
+ @FXML
+ private TextField tf;
+
+ @FXML
+ private TextField tf2;
+
+ @FXML
+ private Button three;
+
+ @FXML
+ private Button two;
+
+ @FXML
+ private Button zero;
+
private int operator ;
double a,b,result ;
String prevStr="";
+
@FXML
private void handleButtonAction(ActionEvent event) {
String str = ((Labeled)event.getSource()).getText();
@@ -81,46 +90,46 @@ private void handleButtonAction(ActionEvent event) {
tf2.setText(prevStr+str);
prevStr = tf2.getText();
}
-
+
@FXML
private void add(){
try{
- a = Double.parseDouble(tf.getText());
- operator = 1 ;
- tf2.setText(prevStr+"+");
- prevStr = tf2.getText();
- }catch(NumberFormatException e){
- System.out.println("Enter value First");
- }finally{
- tf.setText("");
- }
+ a = Double.parseDouble(tf.getText());
+ operator = 1 ;
+ tf2.setText(prevStr+"+");
+ prevStr = tf2.getText();
+ }catch(NumberFormatException e){
+ System.out.println("Enter value First");
+ }finally{
+ tf.setText("");
+ }
}
-
+
@FXML
private void substract(){
- try{
- a = Double.parseDouble(tf.getText());
- operator = 2 ;
- tf2.setText(prevStr+"-");
- prevStr = tf2.getText();
- }catch(NumberFormatException e){
- System.out.println("Enter value First");
- }finally{
- tf.setText("");
- }
+ try{
+ a = Double.parseDouble(tf.getText());
+ operator = 2 ;
+ tf2.setText(prevStr+"-");
+ prevStr = tf2.getText();
+ }catch(NumberFormatException e){
+ System.out.println("Enter value First");
+ }finally{
+ tf.setText("");
+ }
}
-
+
@FXML
private void multiply(){
- try{
+ try{
a = Double.parseDouble(tf.getText());
operator = 3 ;
tf2.setText(prevStr+"*");
prevStr = tf2.getText();
- }catch(NumberFormatException e){
+ }catch(NumberFormatException e){
System.out.println("Enter value First");
}finally{
- tf.setText("");
+ tf.setText("");
}
}
@FXML
@@ -129,10 +138,10 @@ private void clearText(){
tf2.setText("");
prevStr="";
}
-
+
@FXML
private void divide(){
- try{
+ try{
a = Double.parseDouble(tf.getText());
operator = 4 ;
tf2.setText(prevStr+"/");
@@ -143,35 +152,99 @@ private void divide(){
tf.setText("");
}
}
-
+
@FXML
private void equals(){
- try{
- b = Double.parseDouble(tf.getText());
-
- switch(operator){
- case 1 : result = a + b ; tf.setText(""+result); break;
- case 2 : result = a - b ; tf.setText(""+result); break;
- case 3 : result = a * b ; tf.setText(""+result); break;
- case 4 : try{
- result = a/b ;
- tf.setText(""+result);
-
- }catch(Exception e){
- tf.setText("Error");
- }
+ try{
+ b = Double.parseDouble(tf.getText());
+
+ switch(operator){
+ case 1 : result = a + b ; tf.setText(""+result); break;
+ case 2 : result = a - b ; tf.setText(""+result); break;
+ case 3 : result = a * b ; tf.setText(""+result); break;
+ case 4 : try{
+ result = a/b ;
+ tf.setText(""+result);
+
+ }catch(Exception e){
+ tf.setText("Error");
+ }
}
- tf2.setText(prevStr+"="+result);
-
-
-
- }catch(NumberFormatException e){
- System.out.println("Select values First");
- }
-}
+ tf2.setText(prevStr+"="+result);
+
+ }catch(NumberFormatException e){
+ System.out.println("Select values First");
+ }
+ }
+
+ @FXML
+ void fractor(ActionEvent event) {
+ try{
+ a = Double.parseDouble(tf.getText());
+ tf2.setText("");
+ tf2.setText("1/" + a);
+ prevStr = tf2.getText();
+ try{
+ result = 1 / a;
+ }
+ catch (Exception e){
+ tf.setText("Error");
+ }
+ }catch(NumberFormatException e){
+ System.out.println("Enter value First");
+ }finally{
+ tf.setText(""+result);
+ }
+ }
+
+ @FXML
+ void negate(ActionEvent event) {
+ try{
+ a = Double.parseDouble(tf.getText());
+ tf2.setText("");
+ tf2.setText("-" + a);
+ prevStr = tf2.getText();
+ }catch(NumberFormatException e){
+ System.out.println("Enter value First");
+ }finally{
+ tf.setText(""+prevStr);
+ }
+ }
+
+ @FXML
+ void root(ActionEvent event) {
+ try{
+ a = Double.parseDouble(tf.getText());
+ tf2.setText("√" + a);
+ prevStr = tf2.getText();
+ try {
+ result = Math.sqrt(a) ;
+ }
+ catch(Exception e){
+ tf.setText("Error");
+ }
+ }catch(NumberFormatException e){
+ System.out.println("Enter value First");
+ }finally{
+ tf.setText(""+result);
+ }
+ }
+
+ @FXML
+ void squared(ActionEvent event) {
+ try{
+ a = Double.parseDouble(tf.getText());
+ tf2.setText(prevStr+"^2");
+ prevStr = tf2.getText();
+ }catch(NumberFormatException e){
+ System.out.println("Enter value First");
+ }finally{
+ tf.setText(""+ (a * a));
+ }
+ }
+
@Override
- public void initialize(URL url, ResourceBundle rb) {
- // TODO
- }
-
+ public void initialize(URL url, ResourceBundle resourceBundle) {
+
+ }
}