0

i want a calculator project just use applet not swing or frame i hav but i took just input through mouse but dont perform any operation

5
Contributors
6
Replies
7
Views
10 Years
Discussion Span
Last Post by mrark
0

[ok
i make a calculator program which take input form mouse but when i give second input it overrides can u help me pls

0

no, you're beyond help... :(

You do take care to actually remember what the first input was, do you?
Or more likely you don't but should.

0

You did not answer iamthwee question...
All depends what you do and also how much usability you give a user. Do you colect only 2 variables or you let user insert as many values us he/she wish including bracklets, square, power etc? You want simple calculator like windows have or you try to created scientific?

0

I diid all thing but result was the same i m biggner my dear i m sending u the code help if u can

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class KCalculator extends Applet implements ActionListener{

    TextField a ,b,c;
    Button info,clear,equa,plus,minus,divide,mult;
    Button zerow,one,two,three,four,five,six,seven;
    Button eight,nine,point;
    String msg="";
    public void init()
    {
        a=new TextField (12);
        b=new TextField (12);
        c=new TextField (12);
        plus = new Button( "+" );
        minus = new Button( "-" );
        mult = new Button( "*" );
        divide = new Button( "/" );
        zerow = new Button( "0" );
        one = new Button( "1" );
        two = new Button( "2" );
        three = new Button( "3" );
        four = new Button( "4" );
        five = new Button( "5" );
        six = new Button( "6" );
        seven = new Button( "7" );
        eight = new Button( "8" );
        nine = new Button( "9" );

        add( a );
        add( b );
        add( c );
        add( one );
        add( two );
        add( three );
        add( four );
        add( five );
        add( six );
        add( seven );
        add( eight );
        add( nine );
        add( zerow );
        add( plus );
        add( minus );
        add( mult );
        add( divide );

        a.addActionListener(this);
        b.addActionListener(this);
        c.addActionListener(this);
        plus.addActionListener(this);
        minus.addActionListener(this);
        mult.addActionListener(this);
        divide.addActionListener(this);
        zerow.addActionListener(this);
        one.addActionListener(this);
        two.addActionListener(this);
        three.addActionListener(this);
        four.addActionListener(this);
        five.addActionListener(this);
        six.addActionListener(this);
        seven.addActionListener(this);
        eight.addActionListener(this);
        nine.addActionListener(this);
  }


  public void actionPerformed(ActionEvent ae) {
   String str = ae.getActionCommand();
    if(str.equals("0")) {
       a.setText((String) str);
    }else if(str.equals("1")) {
       a.setText((String) str);
    }else if(str.equals("2")) {
       b.setText((String) str);
    }else if(str.equals("3")) {
       a.setText((String) str);
    }else if(str.equals("4")) {
       b.setText((String) str);
    }else if(str.equals("5")) {
       a.setText((String) str);
    }else if(str.equals("6")) {
       b.setText((String) str);
    }else if(str.equals("7")) {
       a.setText((String) str);
    }else if(str.equals("8")) {
       b.setText((String) str);
    }else if(str.equals("9")) {
       a.setText((String) str);
    }else  {
    c.setText((String) str);
    }



 }

}

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.