SlideShare a Scribd company logo
1 of 16
CALCULATOR CODE
importjavafx.application.Application;
importjavafx.event.ActionEvent;
importjavafx.event.EventHandler;
importjavafx.scene.Scene;
importjavafx.scene.control.Button;
importjavafx.scene.control.TextField;
importjavafx.scene.layout.HBox;
importjavafx.scene.layout.VBox;
importjavafx.scene.paint.Color;
importjavafx.scene.text.Font;
importjavafx.stage.Stage;
importjava.lang.Math;
public class main1 extends Application {
String num1 = "";
String num2 = "";
String op;
double result= 0;
boolean oldop =false;
public void start(Stage stage) throws Exception {
Font font =new Font(15);
Button b0 = new Button("0");
b0.setPrefSize(75,35);
b0.setTextFill(Color.BLUE);
Button bdot = new Button(".");
bdot.setPrefSize(75,35);
bdot.setTextFill(Color.BLUE);
Button b1 = new Button("1");
b1.setPrefSize(75,35);
b1.setTextFill(Color.BLUE);
Button b2 = new Button("2");
b2.setPrefSize(75,35);
b2.setTextFill(Color.BLUE);
Button b3 = new Button("3");
b3.setPrefSize(75,35);
b3.setTextFill(Color.BLUE);
Button b4 = new Button("4");
b4.setPrefSize(75,35);
b4.setTextFill(Color.BLUE);
Button b5 = new Button("5");
b5.setPrefSize(75,35);
b5.setTextFill(Color.BLUE);
Button b6 = new Button("6");
b6.setPrefSize(75,35);
b6.setTextFill(Color.BLUE);
Button b7 = new Button("7");
b7.setPrefSize(75,35);
b7.setTextFill(Color.BLUE);
Button b8 = new Button("8");
b8.setPrefSize(75,35);
b8.setTextFill(Color.BLUE);
Button b9 = new Button("9");
b9.setPrefSize(75,35);
b9.setTextFill(Color.BLUE);
Button badd = new Button("+");
badd.setPrefSize(75,35);
badd.setFont(font);
badd.setTextFill(Color.RED);
Button bsub = new Button("-");
bsub.setPrefSize(75,35);
bsub.setFont(font);
bsub.setTextFill(Color.RED);
Button bmul = new Button("*");
bmul.setPrefSize(75,35);
bmul.setFont(font);
bmul.setTextFill(Color.RED);
Button bdiv = new Button("/");
bdiv.setPrefSize(75,35);
bdiv.setFont(font);
bdiv.setTextFill(Color.RED);
Button bsin = new Button("Sin");
bsin.setPrefSize(75,35);
bsin.setTextFill(Color.GOLDENROD);
Button bcos = new Button("Cos");
bcos.setPrefSize(75,35);
bcos.setTextFill(Color.GOLDENROD);
Button btan = new Button("Tan");
btan.setPrefSize(75,35);
btan.setTextFill(Color.GOLDENROD);
Button bsini = new Button("Sin-1");
bsini.setPrefSize(75,35);
bsini.setTextFill(Color.GOLDENROD);
Button bcosi = new Button("Cos-1");
bcosi.setPrefSize(75,35);
bcosi.setTextFill(Color.GOLDENROD);
Button btani = new Button("Tan-1");
btani.setPrefSize(75,35);
btani.setTextFill(Color.GOLDENROD);
Button bsqr = new Button("Sqr");
bsqr.setPrefSize(75,35);
Button bsqrt = new Button("Sqrt");
bsqrt.setPrefSize(75,35);
Button bcub= new Button("Cub");
bcub.setPrefSize(75,35);
Button bcbrt = new Button("Cbrt");
bcbrt.setPrefSize(75,35);
Button blog = new Button("log");
blog.setPrefSize(75,35);
Button bln =new Button("ln");
bln.setPrefSize(75, 35);
Button beql = new Button("=");
beql.setPrefSize(75,35);
Button bac = new Button("AC");
bac.setPrefSize(75,35);
bac.setCursor(null);
bac.setTextFill(Color.GREEN);
TextField txt = new TextField("");
txt.setPrefSize(300, 40);
txt.setCursor(null);
HBox h = new HBox();
h.getChildren().addAll(txt);
HBox h12=new HBox();
h12.getChildren().addAll(bac);
HBox h11 = new HBox();
h11.getChildren().addAll(bsqrt,bcbrt,blog,bln);
HBox h1 = new HBox();
h1.getChildren().addAll(b7, b8, b9, bdiv);
HBox h2 = new HBox();
h2.getChildren().addAll(bsini, bcosi, btani,bcub);
HBox h3 = new HBox();
h3.getChildren().addAll(bsin, bcos, btan,bsqr);
HBox h4 = new HBox();
h4.getChildren().addAll(b4, b5, b6, bmul);
HBox h5 = new HBox();
h5.getChildren().addAll(b1, b2, b3, bsub);
HBox h6 = new HBox();
h6.getChildren().addAll(b0, bdot, beql, badd);
VBox v =new VBox();
v.getChildren().addAll(h,h12, h11, h3, h2, h1, h4, h5,h6);
Scene scene = new Scene(v, 300, 250);
stage.setScene(scene);
stage.show();
bdot.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
num1 += '.';
txt.setText(num1);
} else {
num2 += '.';
txt.setText(num2);
}
}
});
b0.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
num1 += '0';
txt.setText(num1);
} else {
num2 += '0';
txt.setText(num2);
}
}
});
b1.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
num1 += '1';
txt.setText(num1);
} else {
num2 += '1';
txt.setText(num2);
}
}
});
b2.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
num1 += '2';
txt.setText(num1);
} else {
num2 += '2';
txt.setText(num2);
}
}
});
b3.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
num1 += '3';
txt.setText(num1);
} else {
num2 += '3';
txt.setText(num2);
}
}
});
b4.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
num1 += '4';
txt.setText(num1);
} else {
num2 += '4';
txt.setText(num2);
}
}
});
b5.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
num1 += '5';
txt.setText(num1);
} else {
num2 += '5';
txt.setText(num2);
}
}
});
b6.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
num1 += '6';
txt.setText(num1);
} else {
num2 += '6';
txt.setText(num2);
}
}
});
b7.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
num1 += '7';
txt.setText(num1);
} else {
num2 += '7';
txt.setText(num2);
}
}
});
b8.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
num1 += '8';
txt.setText(num1);
} else {
num2 += '8';
txt.setText(num2);
}
}
});
b9.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
num1 += '9';
txt.setText(num1);
} else {
num2 += '9';
txt.setText(num2);
}
}
});
badd.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
oldop = true;
op = "+";
txt.setText(op);
} else {
result = calc(num1, num2, op);
num1 = String.valueOf(result);
num2 = "";
op = "+";
txt.setText(num1 + op);
oldop = true;
}
}
});
bsub.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
oldop = true;
op = "-";
txt.setText(op);
} else {
result = calc(num1, num2, op);
num1 = String.valueOf(result);
num2 = "";
op = "-";
txt.setText(num1 + op);
oldop = true;
}
}
});
bmul.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
oldop = true;
op = "*";
txt.setText(op);
} else {
result = calc(num1, num2, op);
num1 = String.valueOf(result);
num2 = "";
op = "*";
txt.setText(num1 + op);
oldop = true;
}
}
});
bdiv.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (!oldop) {
oldop = true;
op = "/";
txt.setText(op);
} else {
result = calc(num1, num2, op);
num1 = String.valueOf(result);
num2 = "";
op = "/";
txt.setText(num1 + op);
oldop = true;
}
}
});
bsqr.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
num1=txt.getText();
double n1= Double.parseDouble(num1);
double a=Math.pow(n1,2);
txt.setText(String.valueOf(a));
}
});
bsqrt.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
num1=txt.getText();
double n1= Double.parseDouble(num1);
double a=Math.sqrt(n1);
txt.setText(String.valueOf(a));
}
});
bcub.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
num1=txt.getText();
double n1= Double.parseDouble(num1);
double a=Math.pow(n1,3);
txt.setText(String.valueOf(a));
}
});
bcbrt.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
num1=txt.getText();
double n1= Double.parseDouble(num1);
double a=Math.cbrt(n1);
txt.setText(String.valueOf(a));
}
});
bsin.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
num1=txt.getText();
double n1= Double.parseDouble(num1);
txt.setText(num1);
String a=Double.toString( Math.sin(n1));
txt.setText(a);
} });
bcos.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
num1=txt.getText();
double n1= Double.parseDouble(num1);
txt.setText(num1);
String a=Double.toString( Math.cos(n1));
txt.setText(a);
} });
btan.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
num1=txt.getText();
double n1= Double.parseDouble(num1);
txt.setText(num1);
String a=Double.toString( Math.tan(n1));
txt.setText(a);
} });
bsini.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
num1=txt.getText();
double n1= Double.parseDouble(num1);
txt.setText(num1);
String a=Double.toString( Math.sin(n1));
txt.setText(a);
} });
bcosi.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
num1=txt.getText();
double n1= Double.parseDouble(num1);
txt.setText(num1);
String a=Double.toString( Math.cos(n1));
txt.setText(a);
} });
btani.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
num1=txt.getText();
double n1= Double.parseDouble(num1);
txt.setText(num1);
String a=Double.toString( Math.tanh(n1));
txt.setText(a);
} });
blog.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
num1=txt.getText();
double n1= Double.parseDouble(num1);
txt.setText(num1);
String a=Double.toString( Math.log10(n1));
txt.setText(a);
}
});
bln.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
num1=txt.getText();
double n1= Double.parseDouble(num1);
txt.setText(num1);
String a=Double.toString( Math.log(n1));
txt.setText(a);
}
});
beql.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
if (oldop) {
result = calc(num1, num2, op);
txt.setText(String.valueOf(result));
oldop = false;
num2 = "";
} else
return;
}
});
bac.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent arg0) {
num1="0";
num2="0";
result=0;
oldop=false;
op="";
txt.setText("0");
}
});
}
public double calc(String n1, String n2, String op) {
switch (op) {
case "+":
return Double.parseDouble(n1) + Double.parseDouble(n2);
case "-":
return Double.parseDouble(n1) - Double.parseDouble(n2);
case "*":
return Double.parseDouble(n1) * Double.parseDouble(n2);
case "/":
return Double.parseDouble(n1) / Double.parseDouble(n2);
default:
return 0;
}
}
public static void main(String[] args) {
Application.launch(args);
}
}

More Related Content

What's hot

Using Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataUsing Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataMongoDB
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing Swakriti Rathore
 
The Ring programming language version 1.7 book - Part 73 of 196
The Ring programming language version 1.7 book - Part 73 of 196The Ring programming language version 1.7 book - Part 73 of 196
The Ring programming language version 1.7 book - Part 73 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 75 of 202
The Ring programming language version 1.8 book - Part 75 of 202The Ring programming language version 1.8 book - Part 75 of 202
The Ring programming language version 1.8 book - Part 75 of 202Mahmoud Samir Fayed
 
Trisha gee concurrentprogrammingusingthedisruptor
Trisha gee concurrentprogrammingusingthedisruptorTrisha gee concurrentprogrammingusingthedisruptor
Trisha gee concurrentprogrammingusingthedisruptorEthanTu
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 
c++ program for Canteen management
c++ program for Canteen managementc++ program for Canteen management
c++ program for Canteen managementSwarup Kumar Boro
 
Numerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingNumerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingUtsav Patel
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloadingkinan keshkeh
 
Hashing enderecamento aberto bean - bean
Hashing enderecamento aberto bean - beanHashing enderecamento aberto bean - bean
Hashing enderecamento aberto bean - beanElaine Cecília Gatto
 
Oops practical file
Oops practical fileOops practical file
Oops practical fileAnkit Dixit
 
The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189Mahmoud Samir Fayed
 
Introductory RxJava
Introductory RxJavaIntroductory RxJava
Introductory RxJavaIntae Kim
 

What's hot (20)

Using Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your DataUsing Change Streams to Keep Up with Your Data
Using Change Streams to Keep Up with Your Data
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing
 
The Ring programming language version 1.7 book - Part 73 of 196
The Ring programming language version 1.7 book - Part 73 of 196The Ring programming language version 1.7 book - Part 73 of 196
The Ring programming language version 1.7 book - Part 73 of 196
 
The Ring programming language version 1.8 book - Part 75 of 202
The Ring programming language version 1.8 book - Part 75 of 202The Ring programming language version 1.8 book - Part 75 of 202
The Ring programming language version 1.8 book - Part 75 of 202
 
Trisha gee concurrentprogrammingusingthedisruptor
Trisha gee concurrentprogrammingusingthedisruptorTrisha gee concurrentprogrammingusingthedisruptor
Trisha gee concurrentprogrammingusingthedisruptor
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
c++ program for Canteen management
c++ program for Canteen managementc++ program for Canteen management
c++ program for Canteen management
 
Numerical Methods with Computer Programming
Numerical Methods with Computer ProgrammingNumerical Methods with Computer Programming
Numerical Methods with Computer Programming
 
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading2 BytesC++ course_2014_c3_ function basics&parameters and overloading
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
 
Hashing enderecamento aberto bean - bean
Hashing enderecamento aberto bean - beanHashing enderecamento aberto bean - bean
Hashing enderecamento aberto bean - bean
 
Oops lab manual
Oops lab manualOops lab manual
Oops lab manual
 
Oops practical file
Oops practical fileOops practical file
Oops practical file
 
The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180The Ring programming language version 1.5.1 book - Part 63 of 180
The Ring programming language version 1.5.1 book - Part 63 of 180
 
The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189The Ring programming language version 1.6 book - Part 69 of 189
The Ring programming language version 1.6 book - Part 69 of 189
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
A Test of Strength
A Test of StrengthA Test of Strength
A Test of Strength
 
Der perfekte 12c trigger
Der perfekte 12c triggerDer perfekte 12c trigger
Der perfekte 12c trigger
 
informatics practices practical file
informatics practices practical fileinformatics practices practical file
informatics practices practical file
 
Java programs
Java programsJava programs
Java programs
 
Introductory RxJava
Introductory RxJavaIntroductory RxJava
Introductory RxJava
 

Similar to Calculator code with scientific functions in java

openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIopenFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIAtsushi Tadokoro
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql JOYITAKUNDU1
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyYasuharu Nakano
 
The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180Mahmoud Samir Fayed
 
package chapter15;import javafx.application.Application;import j.pdf
package chapter15;import javafx.application.Application;import j.pdfpackage chapter15;import javafx.application.Application;import j.pdf
package chapter15;import javafx.application.Application;import j.pdfKARTIKINDIA
 
Java Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesJava Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesOXUS 20
 
Java Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesJava Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesAbdul Rahman Sherzad
 
The Ring programming language version 1.9 book - Part 78 of 210
The Ring programming language version 1.9 book - Part 78 of 210The Ring programming language version 1.9 book - Part 78 of 210
The Ring programming language version 1.9 book - Part 78 of 210Mahmoud Samir Fayed
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring CanvasKevin Hoyt
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfarihantmum
 
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdfsudhirchourasia86
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)Anders Jönsson
 

Similar to Calculator code with scientific functions in java (20)

662305 11
662305 11662305 11
662305 11
 
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIopenFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
 
The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196
 
The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189The Ring programming language version 1.6 book - Part 70 of 189
The Ring programming language version 1.6 book - Part 70 of 189
 
culadora cientifica en java
culadora cientifica en javaculadora cientifica en java
culadora cientifica en java
 
The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202
 
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180
 
Sbaw091020
Sbaw091020Sbaw091020
Sbaw091020
 
package chapter15;import javafx.application.Application;import j.pdf
package chapter15;import javafx.application.Application;import j.pdfpackage chapter15;import javafx.application.Application;import j.pdf
package chapter15;import javafx.application.Application;import j.pdf
 
Java Unicode with Cool GUI Examples
Java Unicode with Cool GUI ExamplesJava Unicode with Cool GUI Examples
Java Unicode with Cool GUI Examples
 
Java Unicode with Live GUI Examples
Java Unicode with Live GUI ExamplesJava Unicode with Live GUI Examples
Java Unicode with Live GUI Examples
 
The Ring programming language version 1.9 book - Part 78 of 210
The Ring programming language version 1.9 book - Part 78 of 210The Ring programming language version 1.9 book - Part 78 of 210
The Ring programming language version 1.9 book - Part 78 of 210
 
Exploring Canvas
Exploring CanvasExploring Canvas
Exploring Canvas
 
Introduccion a Jasmin
Introduccion a JasminIntroduccion a Jasmin
Introduccion a Jasmin
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
 
teste
testeteste
teste
 
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
  package Chapter_20;import ToolKit.PostfixNotation;import javaf.pdf
 
JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)JavaScript - i och utanför webbläsaren (2010-03-03)
JavaScript - i och utanför webbläsaren (2010-03-03)
 

More from Amna Nawazish

Complete CHAPTER 3 Data Communication.pdf
Complete CHAPTER 3 Data Communication.pdfComplete CHAPTER 3 Data Communication.pdf
Complete CHAPTER 3 Data Communication.pdfAmna Nawazish
 
CHAPTER 3 Data Communication.pdf
CHAPTER 3 Data Communication.pdfCHAPTER 3 Data Communication.pdf
CHAPTER 3 Data Communication.pdfAmna Nawazish
 
MOTION & MANIPULIATION IN ARTIFICIAL INTELLIGENCE.pdf
MOTION & MANIPULIATION IN ARTIFICIAL INTELLIGENCE.pdfMOTION & MANIPULIATION IN ARTIFICIAL INTELLIGENCE.pdf
MOTION & MANIPULIATION IN ARTIFICIAL INTELLIGENCE.pdfAmna Nawazish
 
ELEMENT COMPOUND & MIXTURES ELEMENT
ELEMENT COMPOUND & MIXTURES ELEMENTELEMENT COMPOUND & MIXTURES ELEMENT
ELEMENT COMPOUND & MIXTURES ELEMENTAmna Nawazish
 
Short note Lahore Resolution or Pakistan Resolution 1940, Delhi Proposal 1929...
Short note Lahore Resolution or Pakistan Resolution 1940, Delhi Proposal 1929...Short note Lahore Resolution or Pakistan Resolution 1940, Delhi Proposal 1929...
Short note Lahore Resolution or Pakistan Resolution 1940, Delhi Proposal 1929...Amna Nawazish
 
Life of Ali Ibn Talib
Life of Ali Ibn TalibLife of Ali Ibn Talib
Life of Ali Ibn TalibAmna Nawazish
 
Routing Information Protocol (RIP)
Routing Information Protocol (RIP)Routing Information Protocol (RIP)
Routing Information Protocol (RIP)Amna Nawazish
 
Routing Information Protocol(RIP)
Routing Information Protocol(RIP)Routing Information Protocol(RIP)
Routing Information Protocol(RIP)Amna Nawazish
 
Pros & Cons of globalization
Pros & Cons of globalizationPros & Cons of globalization
Pros & Cons of globalizationAmna Nawazish
 
Online doctor appointment
Online doctor appointmentOnline doctor appointment
Online doctor appointmentAmna Nawazish
 
Term report about igloo ice cream
Term report about igloo ice creamTerm report about igloo ice cream
Term report about igloo ice creamAmna Nawazish
 
Controlling & Motivation
Controlling & MotivationControlling & Motivation
Controlling & MotivationAmna Nawazish
 
Mind Mapping of Management
Mind Mapping of ManagementMind Mapping of Management
Mind Mapping of ManagementAmna Nawazish
 

More from Amna Nawazish (16)

Complete CHAPTER 3 Data Communication.pdf
Complete CHAPTER 3 Data Communication.pdfComplete CHAPTER 3 Data Communication.pdf
Complete CHAPTER 3 Data Communication.pdf
 
CHAPTER 3 Data Communication.pdf
CHAPTER 3 Data Communication.pdfCHAPTER 3 Data Communication.pdf
CHAPTER 3 Data Communication.pdf
 
MOTION & MANIPULIATION IN ARTIFICIAL INTELLIGENCE.pdf
MOTION & MANIPULIATION IN ARTIFICIAL INTELLIGENCE.pdfMOTION & MANIPULIATION IN ARTIFICIAL INTELLIGENCE.pdf
MOTION & MANIPULIATION IN ARTIFICIAL INTELLIGENCE.pdf
 
ELEMENT COMPOUND & MIXTURES ELEMENT
ELEMENT COMPOUND & MIXTURES ELEMENTELEMENT COMPOUND & MIXTURES ELEMENT
ELEMENT COMPOUND & MIXTURES ELEMENT
 
Short note Lahore Resolution or Pakistan Resolution 1940, Delhi Proposal 1929...
Short note Lahore Resolution or Pakistan Resolution 1940, Delhi Proposal 1929...Short note Lahore Resolution or Pakistan Resolution 1940, Delhi Proposal 1929...
Short note Lahore Resolution or Pakistan Resolution 1940, Delhi Proposal 1929...
 
Life of Ali Ibn Talib
Life of Ali Ibn TalibLife of Ali Ibn Talib
Life of Ali Ibn Talib
 
Routing
RoutingRouting
Routing
 
Routing Information Protocol (RIP)
Routing Information Protocol (RIP)Routing Information Protocol (RIP)
Routing Information Protocol (RIP)
 
Routing Information Protocol(RIP)
Routing Information Protocol(RIP)Routing Information Protocol(RIP)
Routing Information Protocol(RIP)
 
External memory
External memoryExternal memory
External memory
 
Pros & Cons of globalization
Pros & Cons of globalizationPros & Cons of globalization
Pros & Cons of globalization
 
Online doctor appointment
Online doctor appointmentOnline doctor appointment
Online doctor appointment
 
Term report about igloo ice cream
Term report about igloo ice creamTerm report about igloo ice cream
Term report about igloo ice cream
 
Controlling & Motivation
Controlling & MotivationControlling & Motivation
Controlling & Motivation
 
Mind Mapping of Management
Mind Mapping of ManagementMind Mapping of Management
Mind Mapping of Management
 
Memo writing
Memo writingMemo writing
Memo writing
 

Recently uploaded

Chemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdfChemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdfSumit Kumar yadav
 
Use of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxUse of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxRenuJangid3
 
Human genetics..........................pptx
Human genetics..........................pptxHuman genetics..........................pptx
Human genetics..........................pptxSilpa
 
Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.Silpa
 
Grade 7 - Lesson 1 - Microscope and Its Functions
Grade 7 - Lesson 1 - Microscope and Its FunctionsGrade 7 - Lesson 1 - Microscope and Its Functions
Grade 7 - Lesson 1 - Microscope and Its FunctionsOrtegaSyrineMay
 
Gwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRL
Gwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRLGwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRL
Gwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRLkantirani197
 
Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Silpa
 
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...Monika Rani
 
Role of AI in seed science Predictive modelling and Beyond.pptx
Role of AI in seed science  Predictive modelling and  Beyond.pptxRole of AI in seed science  Predictive modelling and  Beyond.pptx
Role of AI in seed science Predictive modelling and Beyond.pptxArvind Kumar
 
Genetics and epigenetics of ADHD and comorbid conditions
Genetics and epigenetics of ADHD and comorbid conditionsGenetics and epigenetics of ADHD and comorbid conditions
Genetics and epigenetics of ADHD and comorbid conditionsbassianu17
 
300003-World Science Day For Peace And Development.pptx
300003-World Science Day For Peace And Development.pptx300003-World Science Day For Peace And Development.pptx
300003-World Science Day For Peace And Development.pptxryanrooker
 
FAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical ScienceFAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical ScienceAlex Henderson
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.Silpa
 
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRingsTransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRingsSérgio Sacani
 
THE ROLE OF BIOTECHNOLOGY IN THE ECONOMIC UPLIFT.pptx
THE ROLE OF BIOTECHNOLOGY IN THE ECONOMIC UPLIFT.pptxTHE ROLE OF BIOTECHNOLOGY IN THE ECONOMIC UPLIFT.pptx
THE ROLE OF BIOTECHNOLOGY IN THE ECONOMIC UPLIFT.pptxANSARKHAN96
 
The Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxThe Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxseri bangash
 
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIACURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIADr. TATHAGAT KHOBRAGADE
 
development of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusdevelopment of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusNazaninKarimi6
 
Zoology 5th semester notes( Sumit_yadav).pdf
Zoology 5th semester notes( Sumit_yadav).pdfZoology 5th semester notes( Sumit_yadav).pdf
Zoology 5th semester notes( Sumit_yadav).pdfSumit Kumar yadav
 

Recently uploaded (20)

Chemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdfChemistry 5th semester paper 1st Notes.pdf
Chemistry 5th semester paper 1st Notes.pdf
 
Use of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxUse of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptx
 
Human genetics..........................pptx
Human genetics..........................pptxHuman genetics..........................pptx
Human genetics..........................pptx
 
Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.Phenolics: types, biosynthesis and functions.
Phenolics: types, biosynthesis and functions.
 
Grade 7 - Lesson 1 - Microscope and Its Functions
Grade 7 - Lesson 1 - Microscope and Its FunctionsGrade 7 - Lesson 1 - Microscope and Its Functions
Grade 7 - Lesson 1 - Microscope and Its Functions
 
Gwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRL
Gwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRLGwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRL
Gwalior ❤CALL GIRL 84099*07087 ❤CALL GIRLS IN Gwalior ESCORT SERVICE❤CALL GIRL
 
Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.
 
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS  ESCORT SERVICE In Bhiwan...
Bhiwandi Bhiwandi ❤CALL GIRL 7870993772 ❤CALL GIRLS ESCORT SERVICE In Bhiwan...
 
Role of AI in seed science Predictive modelling and Beyond.pptx
Role of AI in seed science  Predictive modelling and  Beyond.pptxRole of AI in seed science  Predictive modelling and  Beyond.pptx
Role of AI in seed science Predictive modelling and Beyond.pptx
 
Genetics and epigenetics of ADHD and comorbid conditions
Genetics and epigenetics of ADHD and comorbid conditionsGenetics and epigenetics of ADHD and comorbid conditions
Genetics and epigenetics of ADHD and comorbid conditions
 
300003-World Science Day For Peace And Development.pptx
300003-World Science Day For Peace And Development.pptx300003-World Science Day For Peace And Development.pptx
300003-World Science Day For Peace And Development.pptx
 
FAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical ScienceFAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical Science
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
 
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRingsTransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
TransientOffsetin14CAftertheCarringtonEventRecordedbyPolarTreeRings
 
THE ROLE OF BIOTECHNOLOGY IN THE ECONOMIC UPLIFT.pptx
THE ROLE OF BIOTECHNOLOGY IN THE ECONOMIC UPLIFT.pptxTHE ROLE OF BIOTECHNOLOGY IN THE ECONOMIC UPLIFT.pptx
THE ROLE OF BIOTECHNOLOGY IN THE ECONOMIC UPLIFT.pptx
 
The Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxThe Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptx
 
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICEPATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
 
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIACURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
 
development of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusdevelopment of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virus
 
Zoology 5th semester notes( Sumit_yadav).pdf
Zoology 5th semester notes( Sumit_yadav).pdfZoology 5th semester notes( Sumit_yadav).pdf
Zoology 5th semester notes( Sumit_yadav).pdf
 

Calculator code with scientific functions in java

  • 1. CALCULATOR CODE importjavafx.application.Application; importjavafx.event.ActionEvent; importjavafx.event.EventHandler; importjavafx.scene.Scene; importjavafx.scene.control.Button; importjavafx.scene.control.TextField; importjavafx.scene.layout.HBox; importjavafx.scene.layout.VBox; importjavafx.scene.paint.Color; importjavafx.scene.text.Font; importjavafx.stage.Stage; importjava.lang.Math; public class main1 extends Application { String num1 = ""; String num2 = ""; String op; double result= 0; boolean oldop =false; public void start(Stage stage) throws Exception { Font font =new Font(15); Button b0 = new Button("0"); b0.setPrefSize(75,35); b0.setTextFill(Color.BLUE); Button bdot = new Button("."); bdot.setPrefSize(75,35); bdot.setTextFill(Color.BLUE); Button b1 = new Button("1"); b1.setPrefSize(75,35);
  • 2. b1.setTextFill(Color.BLUE); Button b2 = new Button("2"); b2.setPrefSize(75,35); b2.setTextFill(Color.BLUE); Button b3 = new Button("3"); b3.setPrefSize(75,35); b3.setTextFill(Color.BLUE); Button b4 = new Button("4"); b4.setPrefSize(75,35); b4.setTextFill(Color.BLUE); Button b5 = new Button("5"); b5.setPrefSize(75,35); b5.setTextFill(Color.BLUE); Button b6 = new Button("6"); b6.setPrefSize(75,35); b6.setTextFill(Color.BLUE); Button b7 = new Button("7"); b7.setPrefSize(75,35); b7.setTextFill(Color.BLUE); Button b8 = new Button("8"); b8.setPrefSize(75,35); b8.setTextFill(Color.BLUE); Button b9 = new Button("9"); b9.setPrefSize(75,35); b9.setTextFill(Color.BLUE); Button badd = new Button("+"); badd.setPrefSize(75,35); badd.setFont(font); badd.setTextFill(Color.RED); Button bsub = new Button("-"); bsub.setPrefSize(75,35); bsub.setFont(font);
  • 3. bsub.setTextFill(Color.RED); Button bmul = new Button("*"); bmul.setPrefSize(75,35); bmul.setFont(font); bmul.setTextFill(Color.RED); Button bdiv = new Button("/"); bdiv.setPrefSize(75,35); bdiv.setFont(font); bdiv.setTextFill(Color.RED); Button bsin = new Button("Sin"); bsin.setPrefSize(75,35); bsin.setTextFill(Color.GOLDENROD); Button bcos = new Button("Cos"); bcos.setPrefSize(75,35); bcos.setTextFill(Color.GOLDENROD); Button btan = new Button("Tan"); btan.setPrefSize(75,35); btan.setTextFill(Color.GOLDENROD); Button bsini = new Button("Sin-1"); bsini.setPrefSize(75,35); bsini.setTextFill(Color.GOLDENROD); Button bcosi = new Button("Cos-1"); bcosi.setPrefSize(75,35); bcosi.setTextFill(Color.GOLDENROD); Button btani = new Button("Tan-1"); btani.setPrefSize(75,35); btani.setTextFill(Color.GOLDENROD); Button bsqr = new Button("Sqr"); bsqr.setPrefSize(75,35); Button bsqrt = new Button("Sqrt"); bsqrt.setPrefSize(75,35); Button bcub= new Button("Cub");
  • 4. bcub.setPrefSize(75,35); Button bcbrt = new Button("Cbrt"); bcbrt.setPrefSize(75,35); Button blog = new Button("log"); blog.setPrefSize(75,35); Button bln =new Button("ln"); bln.setPrefSize(75, 35); Button beql = new Button("="); beql.setPrefSize(75,35); Button bac = new Button("AC"); bac.setPrefSize(75,35); bac.setCursor(null); bac.setTextFill(Color.GREEN); TextField txt = new TextField(""); txt.setPrefSize(300, 40); txt.setCursor(null); HBox h = new HBox(); h.getChildren().addAll(txt); HBox h12=new HBox(); h12.getChildren().addAll(bac); HBox h11 = new HBox(); h11.getChildren().addAll(bsqrt,bcbrt,blog,bln); HBox h1 = new HBox(); h1.getChildren().addAll(b7, b8, b9, bdiv); HBox h2 = new HBox(); h2.getChildren().addAll(bsini, bcosi, btani,bcub); HBox h3 = new HBox(); h3.getChildren().addAll(bsin, bcos, btan,bsqr); HBox h4 = new HBox(); h4.getChildren().addAll(b4, b5, b6, bmul); HBox h5 = new HBox();
  • 5. h5.getChildren().addAll(b1, b2, b3, bsub); HBox h6 = new HBox(); h6.getChildren().addAll(b0, bdot, beql, badd); VBox v =new VBox(); v.getChildren().addAll(h,h12, h11, h3, h2, h1, h4, h5,h6); Scene scene = new Scene(v, 300, 250); stage.setScene(scene); stage.show(); bdot.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { num1 += '.'; txt.setText(num1); } else { num2 += '.'; txt.setText(num2); } } }); b0.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { num1 += '0'; txt.setText(num1); } else { num2 += '0'; txt.setText(num2); }
  • 6. } }); b1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { num1 += '1'; txt.setText(num1); } else { num2 += '1'; txt.setText(num2); } } }); b2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { num1 += '2'; txt.setText(num1); } else { num2 += '2'; txt.setText(num2); } } }); b3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { num1 += '3'; txt.setText(num1);
  • 7. } else { num2 += '3'; txt.setText(num2); } } }); b4.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { num1 += '4'; txt.setText(num1); } else { num2 += '4'; txt.setText(num2); } } }); b5.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { num1 += '5'; txt.setText(num1); } else { num2 += '5'; txt.setText(num2); } } }); b6.setOnAction(new EventHandler<ActionEvent>() { @Override
  • 8. public void handle(ActionEvent arg0) { if (!oldop) { num1 += '6'; txt.setText(num1); } else { num2 += '6'; txt.setText(num2); } } }); b7.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { num1 += '7'; txt.setText(num1); } else { num2 += '7'; txt.setText(num2); } } }); b8.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { num1 += '8'; txt.setText(num1); } else { num2 += '8'; txt.setText(num2); }
  • 9. } }); b9.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { num1 += '9'; txt.setText(num1); } else { num2 += '9'; txt.setText(num2); } } }); badd.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { oldop = true; op = "+"; txt.setText(op); } else { result = calc(num1, num2, op); num1 = String.valueOf(result); num2 = ""; op = "+"; txt.setText(num1 + op); oldop = true; } } }); bsub.setOnAction(new EventHandler<ActionEvent>() {
  • 10. @Override public void handle(ActionEvent arg0) { if (!oldop) { oldop = true; op = "-"; txt.setText(op); } else { result = calc(num1, num2, op); num1 = String.valueOf(result); num2 = ""; op = "-"; txt.setText(num1 + op); oldop = true; } } }); bmul.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { oldop = true; op = "*"; txt.setText(op); } else { result = calc(num1, num2, op); num1 = String.valueOf(result); num2 = ""; op = "*"; txt.setText(num1 + op); oldop = true; } }
  • 11. }); bdiv.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (!oldop) { oldop = true; op = "/"; txt.setText(op); } else { result = calc(num1, num2, op); num1 = String.valueOf(result); num2 = ""; op = "/"; txt.setText(num1 + op); oldop = true; } } }); bsqr.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { num1=txt.getText(); double n1= Double.parseDouble(num1); double a=Math.pow(n1,2); txt.setText(String.valueOf(a)); } }); bsqrt.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { num1=txt.getText(); double n1= Double.parseDouble(num1);
  • 12. double a=Math.sqrt(n1); txt.setText(String.valueOf(a)); } }); bcub.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { num1=txt.getText(); double n1= Double.parseDouble(num1); double a=Math.pow(n1,3); txt.setText(String.valueOf(a)); } }); bcbrt.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { num1=txt.getText(); double n1= Double.parseDouble(num1); double a=Math.cbrt(n1); txt.setText(String.valueOf(a)); } }); bsin.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { num1=txt.getText(); double n1= Double.parseDouble(num1); txt.setText(num1); String a=Double.toString( Math.sin(n1)); txt.setText(a); } }); bcos.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) {
  • 13. num1=txt.getText(); double n1= Double.parseDouble(num1); txt.setText(num1); String a=Double.toString( Math.cos(n1)); txt.setText(a); } }); btan.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { num1=txt.getText(); double n1= Double.parseDouble(num1); txt.setText(num1); String a=Double.toString( Math.tan(n1)); txt.setText(a); } }); bsini.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { num1=txt.getText(); double n1= Double.parseDouble(num1); txt.setText(num1); String a=Double.toString( Math.sin(n1)); txt.setText(a); } }); bcosi.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { num1=txt.getText(); double n1= Double.parseDouble(num1);
  • 14. txt.setText(num1); String a=Double.toString( Math.cos(n1)); txt.setText(a); } }); btani.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { num1=txt.getText(); double n1= Double.parseDouble(num1); txt.setText(num1); String a=Double.toString( Math.tanh(n1)); txt.setText(a); } }); blog.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { num1=txt.getText(); double n1= Double.parseDouble(num1); txt.setText(num1); String a=Double.toString( Math.log10(n1)); txt.setText(a); } }); bln.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { num1=txt.getText(); double n1= Double.parseDouble(num1); txt.setText(num1);
  • 15. String a=Double.toString( Math.log(n1)); txt.setText(a); } }); beql.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { if (oldop) { result = calc(num1, num2, op); txt.setText(String.valueOf(result)); oldop = false; num2 = ""; } else return; } }); bac.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent arg0) { num1="0"; num2="0"; result=0; oldop=false; op=""; txt.setText("0"); } }); } public double calc(String n1, String n2, String op) { switch (op) {
  • 16. case "+": return Double.parseDouble(n1) + Double.parseDouble(n2); case "-": return Double.parseDouble(n1) - Double.parseDouble(n2); case "*": return Double.parseDouble(n1) * Double.parseDouble(n2); case "/": return Double.parseDouble(n1) / Double.parseDouble(n2); default: return 0; } } public static void main(String[] args) { Application.launch(args); } }