SlideShare a Scribd company logo
1 of 16
package scientific_calculater;
import javax.swing.JOptionPane;
/**
*
* @author Younis
*/
public class Calculater extends javax.swing.JFrame {
private double total1=0.0;
private double total2=0.0;
private double total3=1.0,d;
int sum;
private char math_operater;
/**
* Creates new form Calculater
*/
public Calculater() {
initComponents();
}
private void getOperater(String Btntext)
{
math_operater=Btntext.charAt(0);
total1=total1+Double.parseDouble(calculateroutput.getText());
calculateroutput.setText("");
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jSlider1 = new javax.swing.JSlider();
jPanel1 = new javax.swing.JPanel();
RemainderBtn = new javax.swing.JButton();
MultiplyBtn = new javax.swing.JButton();
ClearBtn = new javax.swing.JButton();
PowerBtn = new javax.swing.JButton();
MinusBtn = new javax.swing.JButton();
Btn9 = new javax.swing.JButton();
DivideBtn = new javax.swing.JButton();
Btn6 = new javax.swing.JButton();
Btn7 = new javax.swing.JButton();
Btn8 = new javax.swing.JButton();
Btn4 = new javax.swing.JButton();
Btn5 = new javax.swing.JButton();
Btn2 = new javax.swing.JButton();
EqualityBtn = new javax.swing.JButton();
Btn0 = new javax.swing.JButton();
ORBtn = new javax.swing.JButton();
ANDBtn = new javax.swing.JButton();
NORBtn = new javax.swing.JButton();
NANDBtn = new javax.swing.JButton();
pointBtn = new javax.swing.JButton();
SquarerootBtn = new javax.swing.JButton();
SignBtn = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
calculateroutput = new javax.swing.JTextPane();
PlusBtn = new javax.swing.JButton();
Btn3 = new javax.swing.JButton();
Btn1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jPanel1.setBackground(new java.awt.Color(102, 102, 102));
jPanel1.setBorder(new javax.swing.border.MatteBorder(null));
jPanel1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
RemainderBtn.setText("%");
RemainderBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
RemainderBtnActionPerformed(evt);
}
});
MultiplyBtn.setText("*");
MultiplyBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MultiplyBtnActionPerformed(evt);
}
});
ClearBtn.setText("C");
ClearBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ClearBtnActionPerformed(evt);
}
});
PowerBtn.setText("^");
PowerBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
PowerBtnActionPerformed(evt);
}
});
MinusBtn.setText("-");
MinusBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MinusBtnActionPerformed(evt);
}
});
Btn9.setText("9");
Btn9.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Btn9ActionPerformed(evt);
}
});
DivideBtn.setText("/");
DivideBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DivideBtnActionPerformed(evt);
}
});
Btn6.setText("6");
Btn6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Btn6ActionPerformed(evt);
}
});
Btn7.setText("7");
Btn7.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Btn7ActionPerformed(evt);
}
});
Btn8.setText("8");
Btn8.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Btn8ActionPerformed(evt);
}
});
Btn4.setText("4");
Btn4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Btn4ActionPerformed(evt);
}
});
Btn5.setText("5");
Btn5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Btn5ActionPerformed(evt);
}
});
Btn2.setText("2");
Btn2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Btn2ActionPerformed(evt);
}
});
EqualityBtn.setText("=");
EqualityBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
EqualityBtnActionPerformed(evt);
}
});
Btn0.setText("0");
Btn0.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Btn0ActionPerformed(evt);
}
});
ORBtn.setText("|");
ORBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ORBtnActionPerformed(evt);
}
});
ANDBtn.setText("&");
ANDBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ANDBtnActionPerformed(evt);
}
});
NORBtn.setText("NOR");
NORBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NORBtnActionPerformed(evt);
}
});
NANDBtn.setText("NAND");
NANDBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NANDBtnActionPerformed(evt);
}
});
pointBtn.setText(".");
pointBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pointBtnActionPerformed(evt);
}
});
SquarerootBtn.setLabel("Square root");
SquarerootBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SquarerootBtnActionPerformed(evt);
}
});
SignBtn.setText("-+");
SignBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
SignBtnActionPerformed(evt);
}
});
calculateroutput.setEditable(false);
calculateroutput.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
calculateroutputKeyPressed(evt);
}
});
jScrollPane1.setViewportView(calculateroutput);
PlusBtn.setText("+");
PlusBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
PlusBtnActionPerformed(evt);
}
});
Btn3.setText("3");
Btn3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Btn3ActionPerformed(evt);
}
});
Btn1.setText("1");
Btn1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Btn1ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new
javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(22, 22, 22)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING, false)
.addComponent(jScrollPane1)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Btn8,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Btn9,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Btn6,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Btn7,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(6, 6, 6)
.addComponent(PowerBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(PlusBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 60,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(ClearBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(RemainderBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(SignBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(MinusBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 60,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addComponent(Btn4,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Btn2,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Btn0,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(6, 6, 6)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Btn1,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(NANDBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 120,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TR
AILING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(MultiplyBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(DivideBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 60,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(Btn3,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pointBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(NORBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 60,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addComponent(Btn5,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(ANDBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 50,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(ORBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 60,
javax.swing.GroupLayout.PREFERRED_SIZE))))))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(EqualityBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 105,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(SquarerootBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 118,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(20, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(68, 68, 68)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 49,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(ClearBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(RemainderBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(SignBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(MinusBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(Btn8, javax.swing.GroupLayout.PREFERRED_SIZE,
30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Btn9, javax.swing.GroupLayout.PREFERRED_SIZE,
30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(PowerBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(PlusBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE
ADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(Btn7,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(DivideBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(MultiplyBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(Btn6, javax.swing.GroupLayout.PREFERRED_SIZE,
30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(Btn4, javax.swing.GroupLayout.PREFERRED_SIZE,
30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Btn5, javax.swing.GroupLayout.PREFERRED_SIZE,
30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(ORBtn, javax.swing.GroupLayout.PREFERRED_SIZE,
30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(ANDBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(Btn2, javax.swing.GroupLayout.PREFERRED_SIZE,
30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(NORBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(pointBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Btn3, javax.swing.GroupLayout.PREFERRED_SIZE,
30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(Btn0, javax.swing.GroupLayout.PREFERRED_SIZE,
30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(NANDBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Btn1, javax.swing.GroupLayout.PREFERRED_SIZE,
30, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
SELINE)
.addComponent(EqualityBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(SquarerootBtn,
javax.swing.GroupLayout.PREFERRED_SIZE, 30,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(88, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(100, 100, 100)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(66, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(110, 110, 110)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(127, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void Btn2ActionPerformed(java.awt.event.ActionEvent evt) {
String btn2=calculateroutput.getText()+Btn2.getText();
calculateroutput.setText(btn2);
}
private void Btn0ActionPerformed(java.awt.event.ActionEvent evt) {
String btn0=calculateroutput.getText()+Btn0.getText();
calculateroutput.setText(btn0);
}
private void Btn1ActionPerformed(java.awt.event.ActionEvent evt) {
String btn1=calculateroutput.getText()+Btn1.getText();
calculateroutput.setText(btn1);
}
private void Btn3ActionPerformed(java.awt.event.ActionEvent evt) {
String btn3=calculateroutput.getText()+Btn3.getText();
calculateroutput.setText(btn3);
}
private void Btn4ActionPerformed(java.awt.event.ActionEvent evt) {
String btn4=calculateroutput.getText()+Btn4.getText();
calculateroutput.setText(btn4);
}
private void Btn5ActionPerformed(java.awt.event.ActionEvent evt) {
String btn5=calculateroutput.getText()+Btn5.getText();
calculateroutput.setText(btn5);
}
private void Btn6ActionPerformed(java.awt.event.ActionEvent evt) {
String btn6=calculateroutput.getText()+Btn6.getText();
calculateroutput.setText(btn6);
}
private void Btn7ActionPerformed(java.awt.event.ActionEvent evt) {
String btn7=calculateroutput.getText()+Btn7.getText();
calculateroutput.setText(btn7);
}
private void Btn8ActionPerformed(java.awt.event.ActionEvent evt) {
String btn8=calculateroutput.getText()+Btn8.getText();
calculateroutput.setText(btn8);
}
private void Btn9ActionPerformed(java.awt.event.ActionEvent evt) {
String btn9=calculateroutput.getText()+Btn9.getText();
calculateroutput.setText(btn9);
}
private void PlusBtnActionPerformed(java.awt.event.ActionEvent evt) {
String Btntext=PlusBtn.getText();
getOperater(Btntext);
}
private void EqualityBtnActionPerformed(java.awt.event.ActionEvent evt) {
switch(math_operater)
{
case '+':
total2=total1+Double.parseDouble(calculateroutput.getText());
calculateroutput.setText(Double.toString(total1)+"+"+calculateroutput.getText()
+"="+"n"+Double.toString(total2));
total1=0;
break;
case '-':
total2=total1-Double.parseDouble(calculateroutput.getText());
calculateroutput.setText(Double.toString(total1)+"-"+calculateroutput.getText()
+"="+"n"+Double.toString(total2));
total1=0;
break;
case '*':
total2=total1*Double.parseDouble(calculateroutput.getText());
calculateroutput.setText(Double.toString(total1)+"*"+calculateroutput.getText()
+"="+"n"+Double.toString(total2));
total1=0;
break;
case '/':
total2=total1/Double.parseDouble(calculateroutput.getText());
calculateroutput.setText(Double.toString(total1)+"/"+calculateroutput.getText()
+"="+"n"+Double.toString(total2));
total1=0;
break;
case '%':
total2=total1%Double.parseDouble(calculateroutput.getText());
calculateroutput.setText(Double.toString(total1)+"%"+calculateroutput.getText()
+"="+"n"+Double.toString(total2));
total1=0;
break;
case '^':
for(double
i=1;i<=Double.parseDouble(calculateroutput.getText());i++)
{
total3=total3*total1;
}
calculateroutput.setText(Double.toString(total1)+"^"+calculateroutput.getText()
+"="+"n"+Double.toString(total3));
total1=0;
break;
case '|':
if(Integer.parseInt(calculateroutput.getText())==1 ||
Integer.parseInt(calculateroutput.getText())==0)
{
total2=(total1)+Integer.parseInt(calculateroutput.getText());
if(total2>0)
{
calculateroutput.setText("True");
}
else
{
calculateroutput.setText("False");
}
}else
{
JOptionPane.showMessageDialog(null, "Please input binary
number and must be single bit");
}
total2=0;
total1=0;
break;
case '&':
if(Integer.parseInt(calculateroutput.getText())==1 ||
Integer.parseInt(calculateroutput.getText())==0)
{
total2=total1*Double.parseDouble(calculateroutput.getText());
if(total2==1)
{
calculateroutput.setText("True");
}
else
{
calculateroutput.setText("False");
}
}
else
{
JOptionPane.showMessageDialog(null, "Please input binary
number and must be single bit");
}
total2=0;
total1=0;
break;
case 'N':
if(Integer.parseInt(calculateroutput.getText())==1 ||
Integer.parseInt(calculateroutput.getText())==0)
{
total2=total1+Double.parseDouble(calculateroutput.getText());
if(total2==0)
{
calculateroutput.setText("True");
}
else
{
calculateroutput.setText("False");
}
}
else
{
JOptionPane.showMessageDialog(null, "Please input binary
number and must be single bit");
}
total2=0;
total1=0;
break;
case 'n':
if(Integer.parseInt(calculateroutput.getText())==1 ||
Integer.parseInt(calculateroutput.getText())==0)
{
total2=total1*Double.parseDouble(calculateroutput.getText());
if(total2==0)
{
calculateroutput.setText("True");
}
else
{
calculateroutput.setText("False");
}
}
else
{
JOptionPane.showMessageDialog(null, "Please input binary
number and must be single bit");
}
total2=0;
total1=0;
break;
}
}
private void MinusBtnActionPerformed(java.awt.event.ActionEvent evt) {
String Btntext=MinusBtn.getText();
getOperater(Btntext);
}
private void DivideBtnActionPerformed(java.awt.event.ActionEvent evt) {
String Btntext=DivideBtn.getText();
getOperater(Btntext);
}
private void MultiplyBtnActionPerformed(java.awt.event.ActionEvent evt) {
String Btntext=MultiplyBtn.getText();
getOperater(Btntext);
}
private void ClearBtnActionPerformed(java.awt.event.ActionEvent evt) {
total2=0;
total3=1;
sum=0;
calculateroutput.setText("");
}
private void SquarerootBtnActionPerformed(java.awt.event.ActionEvent evt) {
double number=Double.parseDouble(calculateroutput.getText());
if(calculateroutput.getText().charAt(0)=='-')
{
JOptionPane.showMessageDialog(null, "Invalid number");
}
else
{
double squareroot=number/2;
do
{
d=squareroot;
squareroot=(d+(number/d))/2;
}
while((d-squareroot)!=0);
calculateroutput.setText(Double.toString(squareroot));
}
}
private void pointBtnActionPerformed(java.awt.event.ActionEvent evt) {
String btnpoint=calculateroutput.getText()+pointBtn.getText();
calculateroutput.setText(btnpoint);
}
private void RemainderBtnActionPerformed(java.awt.event.ActionEvent evt) {
String Btntext=RemainderBtn.getText();
getOperater(Btntext);
}
private void PowerBtnActionPerformed(java.awt.event.ActionEvent evt) {
String Btntext=PowerBtn.getText();
getOperater(Btntext);
}
private void SignBtnActionPerformed(java.awt.event.ActionEvent evt) {
String Sign=Double.toString(total1-
Double.parseDouble(calculateroutput.getText()));
calculateroutput.setText(Sign);
}
private void calculateroutputKeyPressed(java.awt.event.KeyEvent evt) {
JOptionPane.showMessageDialog(null, "Input through Buttons");
String str=calculateroutput.getText();
str="";
calculateroutput.setText(str);
}
private void ORBtnActionPerformed(java.awt.event.ActionEvent evt) {
if(Double.parseDouble(calculateroutput.getText())==1 ||
Double.parseDouble(calculateroutput.getText())==0)
{
String OR=ORBtn.getText();
getOperater(OR);
}
else
{
JOptionPane.showMessageDialog(null, "Please input binary number and
Must be a single Bit");
}
}
private void ANDBtnActionPerformed(java.awt.event.ActionEvent evt) {
if(Double.parseDouble(calculateroutput.getText())==1 ||
Double.parseDouble(calculateroutput.getText())==0)
{
String AND=ANDBtn.getText();
getOperater(AND);
}
else
{
JOptionPane.showMessageDialog(null, "Please input binary number and
Must be a single Bit");
}
}
private void NORBtnActionPerformed(java.awt.event.ActionEvent evt) {
if(Double.parseDouble(calculateroutput.getText())==1 ||
Double.parseDouble(calculateroutput.getText())==0)
{
getOperater("N");
}
else
{
JOptionPane.showMessageDialog(null, "Please input binary number and
Must be a single Bit");
}
}
private void NANDBtnActionPerformed(java.awt.event.ActionEvent evt) {
if(Double.parseDouble(calculateroutput.getText())==1 ||
Double.parseDouble(calculateroutput.getText())==0)
{
getOperater("n");
}
else
{
JOptionPane.showMessageDialog(null, "Please input binary number and
Must be a single Bit");
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting
code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the
default look and feel.
* For details see
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Calculater.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Calculater.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Calculater.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Calculater.class.getName()).log(java.util.log
ging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new Calculater().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton ANDBtn;
private javax.swing.JButton Btn0;
private javax.swing.JButton Btn1;
private javax.swing.JButton Btn2;
private javax.swing.JButton Btn3;
private javax.swing.JButton Btn4;
private javax.swing.JButton Btn5;
private javax.swing.JButton Btn6;
private javax.swing.JButton Btn7;
private javax.swing.JButton Btn8;
private javax.swing.JButton Btn9;
private javax.swing.JButton ClearBtn;
private javax.swing.JButton DivideBtn;
private javax.swing.JButton EqualityBtn;
private javax.swing.JButton MinusBtn;
private javax.swing.JButton MultiplyBtn;
private javax.swing.JButton NANDBtn;
private javax.swing.JButton NORBtn;
private javax.swing.JButton ORBtn;
private javax.swing.JButton PlusBtn;
private javax.swing.JButton PowerBtn;
private javax.swing.JButton RemainderBtn;
private javax.swing.JButton SignBtn;
private javax.swing.JButton SquarerootBtn;
private javax.swing.JTextPane calculateroutput;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSlider jSlider1;
private javax.swing.JButton pointBtn;
// End of variables declaration
}

More Related Content

What's hot

Deep Dive into React Hooks
Deep Dive into React HooksDeep Dive into React Hooks
Deep Dive into React HooksFelix Kühl
 
100% Code Coverage - TDD mit Java EE
100% Code Coverage - TDD mit Java EE100% Code Coverage - TDD mit Java EE
100% Code Coverage - TDD mit Java EEStefan Macke
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developersPavel Lahoda
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon Berlin
 
JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(上)
JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(上)JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(上)
JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(上)Simon Su
 
Testing Android apps based on Dagger and RxJava Droidcon UK
Testing Android apps based on Dagger and RxJava Droidcon UKTesting Android apps based on Dagger and RxJava Droidcon UK
Testing Android apps based on Dagger and RxJava Droidcon UKFabio Collini
 
Js 单元测试框架介绍
Js 单元测试框架介绍Js 单元测试框架介绍
Js 单元测试框架介绍louieuser
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oopLearningTech
 
Android basic 4 Navigation Drawer
Android basic 4 Navigation DrawerAndroid basic 4 Navigation Drawer
Android basic 4 Navigation DrawerEakapong Kattiya
 
Dynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeDynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeMagnify Analytic Solutions
 
Testing Android apps based on Dagger and RxJava
Testing Android apps based on Dagger and RxJavaTesting Android apps based on Dagger and RxJava
Testing Android apps based on Dagger and RxJavaFabio Collini
 
Signalsで Event処理を簡単に
Signalsで Event処理を簡単にSignalsで Event処理を簡単に
Signalsで Event処理を簡単にHiroaki Okubo
 
Selectors and normalizing state shape
Selectors and normalizing state shapeSelectors and normalizing state shape
Selectors and normalizing state shapeMuntasir Chowdhury
 
Swiss army knife Spring
Swiss army knife SpringSwiss army knife Spring
Swiss army knife SpringMario Fusco
 
React Back to the Future
React Back to the FutureReact Back to the Future
React Back to the Future500Tech
 
Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2PRN USM
 

What's hot (19)

Swing
SwingSwing
Swing
 
Android basic 3 Dialogs
Android basic 3 DialogsAndroid basic 3 Dialogs
Android basic 3 Dialogs
 
Android basic 2 UI Design
Android basic 2 UI DesignAndroid basic 2 UI Design
Android basic 2 UI Design
 
Deep Dive into React Hooks
Deep Dive into React HooksDeep Dive into React Hooks
Deep Dive into React Hooks
 
100% Code Coverage - TDD mit Java EE
100% Code Coverage - TDD mit Java EE100% Code Coverage - TDD mit Java EE
100% Code Coverage - TDD mit Java EE
 
Improving android experience for both users and developers
Improving android experience for both users and developersImproving android experience for both users and developers
Improving android experience for both users and developers
 
Droidcon2013 android experience lahoda
Droidcon2013 android experience lahodaDroidcon2013 android experience lahoda
Droidcon2013 android experience lahoda
 
JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(上)
JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(上)JCConf 2015  - 輕鬆學google的雲端開發 - Google App Engine入門(上)
JCConf 2015 - 輕鬆學google的雲端開發 - Google App Engine入門(上)
 
Testing Android apps based on Dagger and RxJava Droidcon UK
Testing Android apps based on Dagger and RxJava Droidcon UKTesting Android apps based on Dagger and RxJava Droidcon UK
Testing Android apps based on Dagger and RxJava Droidcon UK
 
Js 单元测试框架介绍
Js 单元测试框架介绍Js 单元测试框架介绍
Js 单元测试框架介绍
 
Ian 20150116 java script oop
Ian 20150116 java script oopIan 20150116 java script oop
Ian 20150116 java script oop
 
Android basic 4 Navigation Drawer
Android basic 4 Navigation DrawerAndroid basic 4 Navigation Drawer
Android basic 4 Navigation Drawer
 
Dynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using TimeDynamically Evolving Systems: Cluster Analysis Using Time
Dynamically Evolving Systems: Cluster Analysis Using Time
 
Testing Android apps based on Dagger and RxJava
Testing Android apps based on Dagger and RxJavaTesting Android apps based on Dagger and RxJava
Testing Android apps based on Dagger and RxJava
 
Signalsで Event処理を簡単に
Signalsで Event処理を簡単にSignalsで Event処理を簡単に
Signalsで Event処理を簡単に
 
Selectors and normalizing state shape
Selectors and normalizing state shapeSelectors and normalizing state shape
Selectors and normalizing state shape
 
Swiss army knife Spring
Swiss army knife SpringSwiss army knife Spring
Swiss army knife Spring
 
React Back to the Future
React Back to the FutureReact Back to the Future
React Back to the Future
 
Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2
 

Viewers also liked

Die Rebellin
Die RebellinDie Rebellin
Die RebellinAugenblix
 
Commodity Tips By The Market Expert
Commodity Tips By The Market ExpertCommodity Tips By The Market Expert
Commodity Tips By The Market ExpertShiksha Chouhan
 
바다 찌낚시대 고르는 방법(낚시 입문용)
바다 찌낚시대 고르는 방법(낚시 입문용)바다 찌낚시대 고르는 방법(낚시 입문용)
바다 찌낚시대 고르는 방법(낚시 입문용)윤수 이
 
Database normalization using dependencies graph fotache_m_strimbei_c__ibima...
Database normalization using dependencies graph   fotache_m_strimbei_c__ibima...Database normalization using dependencies graph   fotache_m_strimbei_c__ibima...
Database normalization using dependencies graph fotache_m_strimbei_c__ibima...Marin Fotache
 
봄 여름, 자연산 제철 생선회 총정리
봄 여름, 자연산 제철 생선회 총정리봄 여름, 자연산 제철 생선회 총정리
봄 여름, 자연산 제철 생선회 총정리윤수 이
 
시화방조제 낚시 공략
시화방조제 낚시 공략시화방조제 낚시 공략
시화방조제 낚시 공략윤수 이
 

Viewers also liked (7)

Die Rebellin
Die RebellinDie Rebellin
Die Rebellin
 
Testing
TestingTesting
Testing
 
Commodity Tips By The Market Expert
Commodity Tips By The Market ExpertCommodity Tips By The Market Expert
Commodity Tips By The Market Expert
 
바다 찌낚시대 고르는 방법(낚시 입문용)
바다 찌낚시대 고르는 방법(낚시 입문용)바다 찌낚시대 고르는 방법(낚시 입문용)
바다 찌낚시대 고르는 방법(낚시 입문용)
 
Database normalization using dependencies graph fotache_m_strimbei_c__ibima...
Database normalization using dependencies graph   fotache_m_strimbei_c__ibima...Database normalization using dependencies graph   fotache_m_strimbei_c__ibima...
Database normalization using dependencies graph fotache_m_strimbei_c__ibima...
 
봄 여름, 자연산 제철 생선회 총정리
봄 여름, 자연산 제철 생선회 총정리봄 여름, 자연산 제철 생선회 총정리
봄 여름, 자연산 제철 생선회 총정리
 
시화방조제 낚시 공략
시화방조제 낚시 공략시화방조제 낚시 공략
시화방조제 낚시 공략
 

Similar to New text document

20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docxAliHaiderCheema2
 
Exercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera CymbronExercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera Cymbroncymbron
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeletonIram Ramrajkar
 
Cambio de bases
Cambio de basesCambio de bases
Cambio de basesalcon2015
 
Write a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdfWrite a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdffathimaoptical
 
In Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfIn Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfflashfashioncasualwe
 
Java!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfJava!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfarvindarora20042013
 
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfsudhirchourasia86
 
Settings
SettingsSettings
Settingsyito24
 
import javaxswing import javaawtevent import javai.pdf
import javaxswing import javaawtevent import javai.pdfimport javaxswing import javaawtevent import javai.pdf
import javaxswing import javaawtevent import javai.pdfADITIEYEWEAR
 
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
 
Main class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfMain class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfanushkaent7
 
SinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList se.docx
SinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList    se.docxSinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList    se.docx
SinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList se.docxjennifer822
 
I am getting a syntax error. I cant seem to find whats causing t.pdf
I am getting a syntax error. I cant seem to find whats causing t.pdfI am getting a syntax error. I cant seem to find whats causing t.pdf
I am getting a syntax error. I cant seem to find whats causing t.pdffashionfolionr
 

Similar to New text document (20)

Java Assignment Help
Java Assignment HelpJava Assignment Help
Java Assignment Help
 
Maze
MazeMaze
Maze
 
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
20-Arid-850 Ali Haider Cheema BSSE(5A) Evening MPL Assignement 08.docx
 
Exercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera CymbronExercícios Netbeans - Vera Cymbron
Exercícios Netbeans - Vera Cymbron
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
 
Cambio de bases
Cambio de basesCambio de bases
Cambio de bases
 
Write a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdfWrite a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdf
 
In Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfIn Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdf
 
Java!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfJava!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdf
 
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
 
Settings
SettingsSettings
Settings
 
import javaxswing import javaawtevent import javai.pdf
import javaxswing import javaawtevent import javai.pdfimport javaxswing import javaawtevent import javai.pdf
import javaxswing import javaawtevent import javai.pdf
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
code for quiz in my sql
code for quiz  in my sql code for quiz  in my sql
code for quiz in my sql
 
Practical
PracticalPractical
Practical
 
Class 6 2ciclo
Class 6 2cicloClass 6 2ciclo
Class 6 2ciclo
 
Main class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdfMain class --------------------------import java.awt.FlowLayout.pdf
Main class --------------------------import java.awt.FlowLayout.pdf
 
SinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList se.docx
SinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList    se.docxSinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList    se.docx
SinglyLinkedListPseudoCode.txtCLASS SinglyLinkedList se.docx
 
I am getting a syntax error. I cant seem to find whats causing t.pdf
I am getting a syntax error. I cant seem to find whats causing t.pdfI am getting a syntax error. I cant seem to find whats causing t.pdf
I am getting a syntax error. I cant seem to find whats causing t.pdf
 
C# labprograms
C# labprogramsC# labprograms
C# labprograms
 

Recently uploaded

vip Krishna Nagar Call Girls 9999965857 Call or WhatsApp Now Book
vip Krishna Nagar Call Girls 9999965857 Call or WhatsApp Now Bookvip Krishna Nagar Call Girls 9999965857 Call or WhatsApp Now Book
vip Krishna Nagar Call Girls 9999965857 Call or WhatsApp Now Bookmanojkuma9823
 
Call Girls Delhi {Rohini} 9711199012 high profile service
Call Girls Delhi {Rohini} 9711199012 high profile serviceCall Girls Delhi {Rohini} 9711199012 high profile service
Call Girls Delhi {Rohini} 9711199012 high profile servicerehmti665
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...nagunakhan
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一zul5vf0pq
 
办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一
办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一
办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一diploma 1
 
Presentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvfPresentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvfchapmanellie27
 
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service - Bandra F...
WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service -  Bandra F...WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service -  Bandra F...
WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service - Bandra F...Pooja Nehwal
 
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...ur8mqw8e
 
vip Model Basti Call Girls 9999965857 Call or WhatsApp Now Book
vip Model Basti Call Girls 9999965857 Call or WhatsApp Now Bookvip Model Basti Call Girls 9999965857 Call or WhatsApp Now Book
vip Model Basti Call Girls 9999965857 Call or WhatsApp Now Bookmanojkuma9823
 
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一ss ss
 
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一ga6c6bdl
 
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Vip Noida Escorts 9873940964 Greater Noida Escorts Service
Vip Noida Escorts 9873940964 Greater Noida Escorts ServiceVip Noida Escorts 9873940964 Greater Noida Escorts Service
Vip Noida Escorts 9873940964 Greater Noida Escorts Serviceankitnayak356677
 
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service GayaGaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service Gayasrsj9000
 
Hifi Babe North Delhi Call Girl Service Fun Tonight
Hifi Babe North Delhi Call Girl Service Fun TonightHifi Babe North Delhi Call Girl Service Fun Tonight
Hifi Babe North Delhi Call Girl Service Fun TonightKomal Khan
 
Call Girls In Munirka>༒9599632723 Incall_OutCall Available
Call Girls In Munirka>༒9599632723 Incall_OutCall AvailableCall Girls In Munirka>༒9599632723 Incall_OutCall Available
Call Girls In Munirka>༒9599632723 Incall_OutCall AvailableCall Girls in Delhi
 

Recently uploaded (20)

vip Krishna Nagar Call Girls 9999965857 Call or WhatsApp Now Book
vip Krishna Nagar Call Girls 9999965857 Call or WhatsApp Now Bookvip Krishna Nagar Call Girls 9999965857 Call or WhatsApp Now Book
vip Krishna Nagar Call Girls 9999965857 Call or WhatsApp Now Book
 
Call Girls Delhi {Rohini} 9711199012 high profile service
Call Girls Delhi {Rohini} 9711199012 high profile serviceCall Girls Delhi {Rohini} 9711199012 high profile service
Call Girls Delhi {Rohini} 9711199012 high profile service
 
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
Russian Call Girls In South Delhi Delhi 9711199012 💋✔💕😘 Independent Escorts D...
 
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
定制加拿大滑铁卢大学毕业证(Waterloo毕业证书)成绩单(文凭)原版一比一
 
办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一
办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一
办理(CSU毕业证书)澳洲查理斯特大学毕业证成绩单原版一比一
 
Presentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvfPresentation.pptxjnfoigneoifnvoeifnvklfnvf
Presentation.pptxjnfoigneoifnvoeifnvklfnvf
 
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
(SANA) Call Girls Landewadi ( 7001035870 ) HI-Fi Pune Escorts Service
 
WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service - Bandra F...
WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service -  Bandra F...WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service -  Bandra F...
WhatsApp 9892124323 ✓Call Girls In Khar ( Mumbai ) secure service - Bandra F...
 
CIVIL ENGINEERING
CIVIL ENGINEERINGCIVIL ENGINEERING
CIVIL ENGINEERING
 
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
《伯明翰城市大学毕业证成绩单购买》学历证书学位证书区别《复刻原版1:1伯明翰城市大学毕业证书|修改BCU成绩单PDF版》Q微信741003700《BCU学...
 
vip Model Basti Call Girls 9999965857 Call or WhatsApp Now Book
vip Model Basti Call Girls 9999965857 Call or WhatsApp Now Bookvip Model Basti Call Girls 9999965857 Call or WhatsApp Now Book
vip Model Basti Call Girls 9999965857 Call or WhatsApp Now Book
 
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
定制(RHUL学位证)伦敦大学皇家霍洛威学院毕业证成绩单原版一比一
 
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
如何办理伦敦大学伯贝克学院毕业证(BBK毕业证) 成绩单留信学历认证原版一比一
 
Low rate Call girls in Delhi Justdial | 9953330565
Low rate Call girls in Delhi Justdial | 9953330565Low rate Call girls in Delhi Justdial | 9953330565
Low rate Call girls in Delhi Justdial | 9953330565
 
young call girls in Khanpur,🔝 9953056974 🔝 escort Service
young call girls in  Khanpur,🔝 9953056974 🔝 escort Serviceyoung call girls in  Khanpur,🔝 9953056974 🔝 escort Service
young call girls in Khanpur,🔝 9953056974 🔝 escort Service
 
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Bhavna Call 7001035870 Meet With Nagpur Escorts
 
Vip Noida Escorts 9873940964 Greater Noida Escorts Service
Vip Noida Escorts 9873940964 Greater Noida Escorts ServiceVip Noida Escorts 9873940964 Greater Noida Escorts Service
Vip Noida Escorts 9873940964 Greater Noida Escorts Service
 
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service GayaGaya Call Girls #9907093804 Contact Number Escorts Service Gaya
Gaya Call Girls #9907093804 Contact Number Escorts Service Gaya
 
Hifi Babe North Delhi Call Girl Service Fun Tonight
Hifi Babe North Delhi Call Girl Service Fun TonightHifi Babe North Delhi Call Girl Service Fun Tonight
Hifi Babe North Delhi Call Girl Service Fun Tonight
 
Call Girls In Munirka>༒9599632723 Incall_OutCall Available
Call Girls In Munirka>༒9599632723 Incall_OutCall AvailableCall Girls In Munirka>༒9599632723 Incall_OutCall Available
Call Girls In Munirka>༒9599632723 Incall_OutCall Available
 

New text document

  • 1. package scientific_calculater; import javax.swing.JOptionPane; /** * * @author Younis */ public class Calculater extends javax.swing.JFrame { private double total1=0.0; private double total2=0.0; private double total3=1.0,d; int sum; private char math_operater; /** * Creates new form Calculater */ public Calculater() { initComponents(); } private void getOperater(String Btntext) { math_operater=Btntext.charAt(0); total1=total1+Double.parseDouble(calculateroutput.getText()); calculateroutput.setText(""); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jSlider1 = new javax.swing.JSlider(); jPanel1 = new javax.swing.JPanel(); RemainderBtn = new javax.swing.JButton(); MultiplyBtn = new javax.swing.JButton(); ClearBtn = new javax.swing.JButton(); PowerBtn = new javax.swing.JButton(); MinusBtn = new javax.swing.JButton(); Btn9 = new javax.swing.JButton(); DivideBtn = new javax.swing.JButton(); Btn6 = new javax.swing.JButton(); Btn7 = new javax.swing.JButton(); Btn8 = new javax.swing.JButton(); Btn4 = new javax.swing.JButton(); Btn5 = new javax.swing.JButton(); Btn2 = new javax.swing.JButton(); EqualityBtn = new javax.swing.JButton(); Btn0 = new javax.swing.JButton(); ORBtn = new javax.swing.JButton(); ANDBtn = new javax.swing.JButton(); NORBtn = new javax.swing.JButton(); NANDBtn = new javax.swing.JButton(); pointBtn = new javax.swing.JButton(); SquarerootBtn = new javax.swing.JButton(); SignBtn = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); calculateroutput = new javax.swing.JTextPane(); PlusBtn = new javax.swing.JButton(); Btn3 = new javax.swing.JButton(); Btn1 = new javax.swing.JButton();
  • 2. setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); jPanel1.setBackground(new java.awt.Color(102, 102, 102)); jPanel1.setBorder(new javax.swing.border.MatteBorder(null)); jPanel1.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); RemainderBtn.setText("%"); RemainderBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { RemainderBtnActionPerformed(evt); } }); MultiplyBtn.setText("*"); MultiplyBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { MultiplyBtnActionPerformed(evt); } }); ClearBtn.setText("C"); ClearBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ClearBtnActionPerformed(evt); } }); PowerBtn.setText("^"); PowerBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { PowerBtnActionPerformed(evt); } }); MinusBtn.setText("-"); MinusBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { MinusBtnActionPerformed(evt); } }); Btn9.setText("9"); Btn9.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Btn9ActionPerformed(evt); } }); DivideBtn.setText("/"); DivideBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { DivideBtnActionPerformed(evt); } }); Btn6.setText("6"); Btn6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Btn6ActionPerformed(evt); } }); Btn7.setText("7");
  • 3. Btn7.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Btn7ActionPerformed(evt); } }); Btn8.setText("8"); Btn8.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Btn8ActionPerformed(evt); } }); Btn4.setText("4"); Btn4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Btn4ActionPerformed(evt); } }); Btn5.setText("5"); Btn5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Btn5ActionPerformed(evt); } }); Btn2.setText("2"); Btn2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Btn2ActionPerformed(evt); } }); EqualityBtn.setText("="); EqualityBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EqualityBtnActionPerformed(evt); } }); Btn0.setText("0"); Btn0.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Btn0ActionPerformed(evt); } }); ORBtn.setText("|"); ORBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ORBtnActionPerformed(evt); } }); ANDBtn.setText("&"); ANDBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ANDBtnActionPerformed(evt); } }); NORBtn.setText("NOR"); NORBtn.addActionListener(new java.awt.event.ActionListener() {
  • 4. public void actionPerformed(java.awt.event.ActionEvent evt) { NORBtnActionPerformed(evt); } }); NANDBtn.setText("NAND"); NANDBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { NANDBtnActionPerformed(evt); } }); pointBtn.setText("."); pointBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { pointBtnActionPerformed(evt); } }); SquarerootBtn.setLabel("Square root"); SquarerootBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SquarerootBtnActionPerformed(evt); } }); SignBtn.setText("-+"); SignBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SignBtnActionPerformed(evt); } }); calculateroutput.setEditable(false); calculateroutput.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { calculateroutputKeyPressed(evt); } }); jScrollPane1.setViewportView(calculateroutput); PlusBtn.setText("+"); PlusBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { PlusBtnActionPerformed(evt); } }); Btn3.setText("3"); Btn3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Btn3ActionPerformed(evt); } }); Btn1.setText("1"); Btn1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { Btn1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
  • 5. jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(22, 22, 22) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING, false) .addComponent(jScrollPane1) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(Btn8, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(Btn9, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(Btn6, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(Btn7, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(6, 6, 6) .addComponent(PowerBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(PlusBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(ClearBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(RemainderBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(SignBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(MinusBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING)
  • 6. .addComponent(Btn4, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Btn2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Btn0, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(6, 6, 6) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(Btn1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(NANDBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TR AILING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(MultiplyBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(DivideBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING, false) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(Btn3, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(pointBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(NORBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addComponent(Btn5, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(ANDBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
  • 7. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(ORBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))))) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(EqualityBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(SquarerootBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(20, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(68, 68, 68) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA SELINE) .addComponent(ClearBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(RemainderBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(SignBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(MinusBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA SELINE) .addComponent(Btn8, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Btn9, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(PowerBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(PlusBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA
  • 8. SELINE) .addComponent(Btn7, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(DivideBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(MultiplyBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(Btn6, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA SELINE) .addComponent(Btn4, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Btn5, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ORBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(ANDBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA SELINE) .addComponent(Btn2, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(NORBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pointBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Btn3, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA SELINE) .addComponent(Btn0, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(NANDBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(Btn1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BA SELINE) .addComponent(EqualityBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(SquarerootBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
  • 9. .addContainerGap(88, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(100, 100, 100) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(66, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(110, 110, 110) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(127, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void Btn2ActionPerformed(java.awt.event.ActionEvent evt) { String btn2=calculateroutput.getText()+Btn2.getText(); calculateroutput.setText(btn2); } private void Btn0ActionPerformed(java.awt.event.ActionEvent evt) { String btn0=calculateroutput.getText()+Btn0.getText(); calculateroutput.setText(btn0); } private void Btn1ActionPerformed(java.awt.event.ActionEvent evt) { String btn1=calculateroutput.getText()+Btn1.getText(); calculateroutput.setText(btn1); } private void Btn3ActionPerformed(java.awt.event.ActionEvent evt) { String btn3=calculateroutput.getText()+Btn3.getText(); calculateroutput.setText(btn3); } private void Btn4ActionPerformed(java.awt.event.ActionEvent evt) { String btn4=calculateroutput.getText()+Btn4.getText(); calculateroutput.setText(btn4); } private void Btn5ActionPerformed(java.awt.event.ActionEvent evt) {
  • 10. String btn5=calculateroutput.getText()+Btn5.getText(); calculateroutput.setText(btn5); } private void Btn6ActionPerformed(java.awt.event.ActionEvent evt) { String btn6=calculateroutput.getText()+Btn6.getText(); calculateroutput.setText(btn6); } private void Btn7ActionPerformed(java.awt.event.ActionEvent evt) { String btn7=calculateroutput.getText()+Btn7.getText(); calculateroutput.setText(btn7); } private void Btn8ActionPerformed(java.awt.event.ActionEvent evt) { String btn8=calculateroutput.getText()+Btn8.getText(); calculateroutput.setText(btn8); } private void Btn9ActionPerformed(java.awt.event.ActionEvent evt) { String btn9=calculateroutput.getText()+Btn9.getText(); calculateroutput.setText(btn9); } private void PlusBtnActionPerformed(java.awt.event.ActionEvent evt) { String Btntext=PlusBtn.getText(); getOperater(Btntext); } private void EqualityBtnActionPerformed(java.awt.event.ActionEvent evt) { switch(math_operater) { case '+': total2=total1+Double.parseDouble(calculateroutput.getText()); calculateroutput.setText(Double.toString(total1)+"+"+calculateroutput.getText() +"="+"n"+Double.toString(total2)); total1=0; break; case '-': total2=total1-Double.parseDouble(calculateroutput.getText()); calculateroutput.setText(Double.toString(total1)+"-"+calculateroutput.getText() +"="+"n"+Double.toString(total2)); total1=0; break; case '*': total2=total1*Double.parseDouble(calculateroutput.getText()); calculateroutput.setText(Double.toString(total1)+"*"+calculateroutput.getText() +"="+"n"+Double.toString(total2)); total1=0;
  • 11. break; case '/': total2=total1/Double.parseDouble(calculateroutput.getText()); calculateroutput.setText(Double.toString(total1)+"/"+calculateroutput.getText() +"="+"n"+Double.toString(total2)); total1=0; break; case '%': total2=total1%Double.parseDouble(calculateroutput.getText()); calculateroutput.setText(Double.toString(total1)+"%"+calculateroutput.getText() +"="+"n"+Double.toString(total2)); total1=0; break; case '^': for(double i=1;i<=Double.parseDouble(calculateroutput.getText());i++) { total3=total3*total1; } calculateroutput.setText(Double.toString(total1)+"^"+calculateroutput.getText() +"="+"n"+Double.toString(total3)); total1=0; break; case '|': if(Integer.parseInt(calculateroutput.getText())==1 || Integer.parseInt(calculateroutput.getText())==0) { total2=(total1)+Integer.parseInt(calculateroutput.getText()); if(total2>0) { calculateroutput.setText("True"); } else { calculateroutput.setText("False"); } }else { JOptionPane.showMessageDialog(null, "Please input binary number and must be single bit"); } total2=0; total1=0; break; case '&': if(Integer.parseInt(calculateroutput.getText())==1 || Integer.parseInt(calculateroutput.getText())==0) { total2=total1*Double.parseDouble(calculateroutput.getText()); if(total2==1) { calculateroutput.setText("True"); } else { calculateroutput.setText("False"); } } else
  • 12. { JOptionPane.showMessageDialog(null, "Please input binary number and must be single bit"); } total2=0; total1=0; break; case 'N': if(Integer.parseInt(calculateroutput.getText())==1 || Integer.parseInt(calculateroutput.getText())==0) { total2=total1+Double.parseDouble(calculateroutput.getText()); if(total2==0) { calculateroutput.setText("True"); } else { calculateroutput.setText("False"); } } else { JOptionPane.showMessageDialog(null, "Please input binary number and must be single bit"); } total2=0; total1=0; break; case 'n': if(Integer.parseInt(calculateroutput.getText())==1 || Integer.parseInt(calculateroutput.getText())==0) { total2=total1*Double.parseDouble(calculateroutput.getText()); if(total2==0) { calculateroutput.setText("True"); } else { calculateroutput.setText("False"); } } else { JOptionPane.showMessageDialog(null, "Please input binary number and must be single bit"); } total2=0; total1=0; break; } } private void MinusBtnActionPerformed(java.awt.event.ActionEvent evt) { String Btntext=MinusBtn.getText(); getOperater(Btntext); }
  • 13. private void DivideBtnActionPerformed(java.awt.event.ActionEvent evt) { String Btntext=DivideBtn.getText(); getOperater(Btntext); } private void MultiplyBtnActionPerformed(java.awt.event.ActionEvent evt) { String Btntext=MultiplyBtn.getText(); getOperater(Btntext); } private void ClearBtnActionPerformed(java.awt.event.ActionEvent evt) { total2=0; total3=1; sum=0; calculateroutput.setText(""); } private void SquarerootBtnActionPerformed(java.awt.event.ActionEvent evt) { double number=Double.parseDouble(calculateroutput.getText()); if(calculateroutput.getText().charAt(0)=='-') { JOptionPane.showMessageDialog(null, "Invalid number"); } else { double squareroot=number/2; do { d=squareroot; squareroot=(d+(number/d))/2; } while((d-squareroot)!=0); calculateroutput.setText(Double.toString(squareroot)); } } private void pointBtnActionPerformed(java.awt.event.ActionEvent evt) { String btnpoint=calculateroutput.getText()+pointBtn.getText(); calculateroutput.setText(btnpoint); } private void RemainderBtnActionPerformed(java.awt.event.ActionEvent evt) { String Btntext=RemainderBtn.getText(); getOperater(Btntext); } private void PowerBtnActionPerformed(java.awt.event.ActionEvent evt) { String Btntext=PowerBtn.getText(); getOperater(Btntext); } private void SignBtnActionPerformed(java.awt.event.ActionEvent evt) { String Sign=Double.toString(total1- Double.parseDouble(calculateroutput.getText()));
  • 14. calculateroutput.setText(Sign); } private void calculateroutputKeyPressed(java.awt.event.KeyEvent evt) { JOptionPane.showMessageDialog(null, "Input through Buttons"); String str=calculateroutput.getText(); str=""; calculateroutput.setText(str); } private void ORBtnActionPerformed(java.awt.event.ActionEvent evt) { if(Double.parseDouble(calculateroutput.getText())==1 || Double.parseDouble(calculateroutput.getText())==0) { String OR=ORBtn.getText(); getOperater(OR); } else { JOptionPane.showMessageDialog(null, "Please input binary number and Must be a single Bit"); } } private void ANDBtnActionPerformed(java.awt.event.ActionEvent evt) { if(Double.parseDouble(calculateroutput.getText())==1 || Double.parseDouble(calculateroutput.getText())==0) { String AND=ANDBtn.getText(); getOperater(AND); } else { JOptionPane.showMessageDialog(null, "Please input binary number and Must be a single Bit"); } } private void NORBtnActionPerformed(java.awt.event.ActionEvent evt) { if(Double.parseDouble(calculateroutput.getText())==1 || Double.parseDouble(calculateroutput.getText())==0) { getOperater("N"); } else { JOptionPane.showMessageDialog(null, "Please input binary number and Must be a single Bit"); } } private void NANDBtnActionPerformed(java.awt.event.ActionEvent evt) { if(Double.parseDouble(calculateroutput.getText())==1 || Double.parseDouble(calculateroutput.getText())==0) { getOperater("n"); }
  • 15. else { JOptionPane.showMessageDialog(null, "Please input binary number and Must be a single Bit"); } } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(Calculater.class.getName()).log(java.util.log ging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(Calculater.class.getName()).log(java.util.log ging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(Calculater.class.getName()).log(java.util.log ging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(Calculater.class.getName()).log(java.util.log ging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { new Calculater().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton ANDBtn; private javax.swing.JButton Btn0; private javax.swing.JButton Btn1; private javax.swing.JButton Btn2; private javax.swing.JButton Btn3; private javax.swing.JButton Btn4; private javax.swing.JButton Btn5; private javax.swing.JButton Btn6;
  • 16. private javax.swing.JButton Btn7; private javax.swing.JButton Btn8; private javax.swing.JButton Btn9; private javax.swing.JButton ClearBtn; private javax.swing.JButton DivideBtn; private javax.swing.JButton EqualityBtn; private javax.swing.JButton MinusBtn; private javax.swing.JButton MultiplyBtn; private javax.swing.JButton NANDBtn; private javax.swing.JButton NORBtn; private javax.swing.JButton ORBtn; private javax.swing.JButton PlusBtn; private javax.swing.JButton PowerBtn; private javax.swing.JButton RemainderBtn; private javax.swing.JButton SignBtn; private javax.swing.JButton SquarerootBtn; private javax.swing.JTextPane calculateroutput; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSlider jSlider1; private javax.swing.JButton pointBtn; // End of variables declaration }