Calculator help plz..i really need help!
ok so im making a Calculator..and i got the graphic part..and id ont know how to do the math..
i got 2 files one for the graphic..and the other for the math..for like the caluction
import java.awt.*;
import java.awt.event.*;
public class Calculatorsgui extends Frame implements WindowListener
{
protected Button plus, subract, times, divide, exitButton;
protected TextField input1, input2, answer;
private Calculatorsgui controller;
public Calculatorsgui ()
{
setTitle ("Calculator"); // Set the frame's name
setLayout (new FlowLayout (FlowLayout.CENTER));
setSize (180, 180); // Set the frame's size
// SimpleController is a class that handles the button clicks
CalculatorsController controller = new CalculatorsController (this);
// Adding an empty non-editable text field
Label l = new Label ("Number1");
add ("South", l);
input1 = new TextField (10);
input1.setEditable (true);
add ("Center", input1);
Label a = new Label ("Number2");
add ("South", a);
input2 = new TextField (10);
input2.setEditable (true);
add ("Center", input2);
// add buttons to the frame and connect the controller to it
plus = new Button ("+");
plus.addActionListener (controller);
add (plus);
subract = new Button ("-");
subract.addActionListener (controller);
add (subract);
times = new Button ("*");
times.addActionListener (controller);
add (times);
divide = new Button ("/");
divide.addActionListener (controller);
add (divide);
Label b = new Label ("The Answer");
add ("South", b);
answer = new TextField (10);
answer.setEditable (false);
add ("Center", answer);
exitButton = new Button ("exit");
exitButton.addActionListener (controller);
add (exitButton);
// Make the frame handle window events
addWindowListener (this);
show (); // Show the frame or use setVisible (true)
} // Constructor
public void paint (Graphics g)
{
// Place the drawing code here
} // paint method
public void windowDeiconified (WindowEvent event)
{
}
public void windowIconified (WindowEvent event)
{
}
public void windowActivated (WindowEvent event)
{
}
public void windowDeactivated (WindowEvent event)
{
}
public void windowClosed (WindowEvent event)
{
}
public void windowClosing (WindowEvent event)
{
System.exit (0);
}
public void windowOpened (WindowEvent event)
{
}
public static void main (String[] args)
{
new Calculatorsgui (); // Create a SimpleExample frame
} // main method
}
then for my sencond file..i have no idea wat to do!this is wat i got..i need adding..and divide..and subtract
import java.awt.*;
import java.awt.event.*;
public class CalculatorsController implements ActionListener
{
Calculatorsgui view;
public CalculatorsController (Calculatorsgui view)
{
this.view = view;
}
public void actionPerformed (ActionEvent event)
{
// You can get the source object of an event
Object source = event.getSource ();
//You can compare the event source with actual objects.
if (source == view.exitButton)
System.exit (0);
so if anyone can do thing for me..u be my hero..no JOKES!!!!!!!!!! PLEASE HELP ..im on my knees