Calculator R

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

private void setAll(String s)

{
String all=display.getText()+s;
display.setText(all);
}
private void offActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
this.dispose();
}
private void n1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
setAll("1");
}
private void n2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
setAll("2");
}
private void n3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
setAll("3");
}
private void n4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
setAll("4");
}
private void n5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
setAll("5");
}
private void n6ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
setAll("6");
}
private void n7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
setAll("7");
}
private void n8ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
setAll("8");
}
private void n9ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:


setAll("9");
}
private void n0ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
setAll("0");
}
private void dotActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
setAll(".");
}
private void clearActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
display.setText("");
}
private void addActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
num1=Double.parseDouble(display.getText());
display.setText("");
opr='+';
}
private void subActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
num1=Double.parseDouble(display.getText());
display.setText("");
opr='-';
}
private void mulActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
num1=Double.parseDouble(display.getText());
display.setText("");
opr='*';
}
private void divActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
num1=Double.parseDouble(display.getText());
display.setText("");
opr='/';
}
private void equalActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
num2=Double.parseDouble(display.getText());
switch(opr)

{
case '+'
break;
case '-'
break;
case '*'
break;
case '/'

: result1=num1+num2;
: result1=num1-num2;
: result1=num1*num2;
:

result1=num1/num2;
break;
}
display.setText(String.valueOf(result1));
}
//end

You might also like