This is the coding i took from this forum which i need.By running this program iam getting add,minus,plus and div,but not sine,cos n tan.plz tell me the problem in this coding.It will be useful for me.


import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class MyCalculator extends JApplet implements ActionListener {
private char op = 0;
private float num1 = 0, num2 = 0, value = 0 ;
private boolean clearNext = false;
private JTextField display, textField2;
private JButton buttonEq, buttonPlus, buttonMinus, buttonMult,buttonCos;
private JButton buttonDiv,buttonPlusMinus,buttonDec,buttonC,button Sin;
private JButton buttonTan;
private JButton button = new JButton();
private boolean start = true;

// create GUI components
public void init() {
Container con = getContentPane();
con.setLayout( new BorderLayout());
con.setBackground(Color.darkGray);
//add display display
display = new JTextField( "0", 15 );
display.setBackground(Color.black);
display.setForeground(Color.red);
display.setEditable(false);

textField2 = new JTextField( " Design and Implementation By Erwin Zeitner" );
textField2.setBackground(Color.black);
textField2.setForeground(Color.red);
textField2.setEditable(false);

//create numbered buttons
JButton button0 = new JButton("0" );
button0.setBackground(Color.blue);
JButton button1 = new JButton( "1" );
button1.setBackground(Color.blue);
JButton button2 = new JButton( "2" );
button2.setBackground(Color.blue);
JButton button3 = new JButton( "3" );
button3.setBackground(Color.blue);
JButton button4 = new JButton( "4" );
button4.setBackground(Color.blue);
JButton button5 = new JButton( "5" );
button5.setBackground(Color.blue);
JButton button6 = new JButton( "6" );
button6.setBackground(Color.blue);
JButton button7 = new JButton( "7" );
button7.setBackground(Color.blue);
JButton button8 = new JButton( "8" );
button8.setBackground(Color.blue);
JButton button9 = new JButton( "9" );
button9.setBackground(Color.blue);

//create function buttons
buttonC = new JButton( "clear" );
buttonC.setBackground(Color.green);
buttonPlus = new JButton( "+" );
buttonPlus.setBackground(Color.green);
buttonMinus = new JButton( "-" );
buttonMinus.setBackground(Color.green);
buttonMult = new JButton( "*" );
buttonMult.setBackground(Color.green);
buttonDiv = new JButton( "/" );
buttonDiv.setBackground(Color.green);
buttonSin = new JButton( "Sin" );
buttonSin.setBackground(Color.green);
buttonCos = new JButton( "Cos" );
buttonCos.setBackground(Color.green);
buttonTan = new JButton( "Tan" );
buttonTan.setBackground(Color.green);
buttonDec = new JButton( "." );
buttonDec.setBackground(Color.blue);
buttonEq = new JButton( "=" );
buttonEq.setBackground(Color.orange);
buttonPlusMinus = new JButton( "+/-" );
buttonPlusMinus.setBackground(Color.blue);

//create a panel for each row
JPanel row1 = new JPanel();
row1.setBackground(Color.darkGray);
JPanel row2 = new JPanel();
row2.setBackground(Color.darkGray);
JPanel row3 = new JPanel();
row3.setBackground(Color.darkGray);
JPanel row4 = new JPanel();
row4.setBackground(Color.darkGray);
JPanel row5 = new JPanel();
row5.setBackground(Color.darkGray);
JPanel row6 = new JPanel();
row6.setBackground(Color.darkGray);
JPanel row7 = new JPanel();
row7.setBackground(Color.darkGray);

//create panel for rows and set layout
JPanel p = new JPanel();
p.setLayout(new GridLayout( 7,1,0,5 ));
p.setBackground(Color.darkGray);
//set layout for rows
GridLayout grid = new GridLayout(1,4,5,0);

//add buttons & display field to rows
row1.setLayout(grid);
row1.add(display);
//add row to panel
p.add(row1);

row2.setLayout(grid);
buttonC.addActionListener(this);
row2.add(buttonC);
buttonSin.addActionListener(this);
row2.add(buttonSin);
buttonCos.addActionListener(this);
row2.add(buttonCos);
buttonTan.addActionListener(this);
row2.add(buttonTan);
//add row to panel
p.add(row2);

row3.setLayout(grid);
button7.addActionListener(this);
row3.add(button7);
button8.addActionListener(this);
row3.add(button8);
button9.addActionListener(this);
row3.add(button9);
buttonPlus.addActionListener(this);
row3.add(buttonPlus);
//add row to panel
p.add(row3);

row4.setLayout(grid);
button4.addActionListener(this);
row4.add(button4);
button5.addActionListener(this);
row4.add(button5);
button6.addActionListener(this);
row4.add(button6);
buttonMinus.addActionListener(this);
row4.add(buttonMinus);
//add row to panel
p.add(row4);

row5.setLayout(grid);
button1.addActionListener(this);
row5.add(button1);
button2.addActionListener(this);
row5.add(button2);
button3.addActionListener(this);
row5.add(button3);
buttonMult.addActionListener(this);
row5.add(buttonMult);
//add row to panel
p.add(row5);

row6.setLayout(grid);
button0.addActionListener(this);
row6.add(button0);
buttonDec.addActionListener(this);
row6.add(buttonDec);
buttonPlusMinus.addActionListener(this);
row6.add(buttonPlusMinus);
buttonDiv.addActionListener(this);
row6.add(buttonDiv);
//add row to panel
p.add(row6);

row7.setLayout(grid);
buttonEq.addActionListener(this);
row7.add(buttonEq);
//add row to panel
p.add(row7);

// add panel and textField2 to the container
con.add(p,BorderLayout.CENTER);
con.add(textField2,BorderLayout.SOUTH);
}

public void actionPerformed(ActionEvent e) {
String buttonPressed = e.getActionCommand();
try {
if (buttonPressed.equals( "+/-" )) {
value = getValue(display.getText());
value *= -1;
clearOutput();
addToOutput("" + value );
}
else switch ( buttonPressed.charAt(0) ) {
case '+':
case '-':
case '*':
case '/':
buttonEq.setEnabled(true);
buttonPlus.setEnabled(false);
buttonMinus.setEnabled(false);
buttonMult.setEnabled(false);
buttonDiv.setEnabled(false);
num1 = getValue(display.getText());
op = buttonPressed.charAt(0);
clearNext = true;
break;
case '=':
buttonEq.setEnabled(true);
buttonPlus.setEnabled(true);
buttonMinus.setEnabled(true);
buttonMult.setEnabled(true);
buttonDiv.setEnabled(true);
getResult();
num1 = getValue(display.getText());
op = 0 ;
clearNext = true;
break;
case 'C':
float num1 = getValue(display.getText());
op = buttonPressed.charAt(0);
getResult();
clearNext = false;
break;
case 'S':
num1 = getValue(display.getText());
op = buttonPressed.charAt(0);
getResult();
clearNext = false;
break;
case 'T':
num1 = getValue(display.getText());
op = buttonPressed.charAt(0);
getResult();
clearNext = false;
break;
case 'c':
clearOutput();
op = 0 ;
num1 = (float) 0 ;
break;
default:
if (clearNext) {
clearOutput();
clearNext = false;
}
addToOutput(buttonPressed);
}
}
catch( Exception exception) {
System.err.println(exception.toString());
}
}

public void getResult() {
float num2 = getValue(display.getText());
switch (op) {
case '+':
num1 += num2;
break;
case '-':
num1 -= num2;
break;
case '*':
num1 *= num2;
break;
case '/':
if (num2 != 0)
num1 /= num2;
else
num1 = 0;
break;
case 'C':
Math.cos(num1);
break;
case 'S':
Math.sin(num1);
break;
case 'T':
Math.tan(num1);
break;
}
clearOutput();
addToOutput( "" + num1 );
clearNext = true;
}

public void addToOutput( String buttonPressed) {
String newOutput = display.getText();
if (buttonPressed.equals(".")) {
if (newOutput.indexOf(".") == -1)
newOutput += ".";
}
else
newOutput += buttonPressed;
int newLength = newOutput.length();
display.setText(newOutput);
}

public void clearOutput() {
try{
display.setText( "" );
}
catch(Exception c) {
System.err.println(c.toString());
}
}

public float getValue(String arg) {
if (arg.equals("."))
arg = "0";
Float f = Float.valueOf(arg);
return f.floatValue();
}
}