×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    214

    Red face Evaluvate when the equal to button is pressed

    Hi can u help me in the project on calculator ................how can I get the value when I press the = button c I have wrriten as follows

    public void doOperations()
    {
    {
    if(valueone.equals(""))
    {
    valueone = txt.getText();
    operation = operand;
    secondValueStarted = false;
    }
    if(operand.equals("="))
    {
    valuetwo = txt.getText();
    if(operation.equals("+"))
    {
    float result = Float.parseFloat(valueone) + Float.parseFloat(valuetwo);
    resetCalculator();
    txt.setText(String.valueOf(result));
    }
    if(operation.equals("-"))
    {
    float result = Float.parseFloat(valueone) - Float.parseFloat(valuetwo);
    resetCalculator();
    txt.setText(String.valueOf(result));
    }
    if(operation.equals("*"))
    {
    float result = Float.parseFloat(valueone) * Float.parseFloat(valuetwo);
    resetCalculator();
    txt.setText(String.valueOf(result));
    }
    if(operation.equals("/"))
    {
    float result = Float.parseFloat(valueone) / Float.parseFloat(valuetwo);
    resetCalculator();
    txt.setText(String.valueOf(result));
    }
    }
    }

    }

    and I have globally declared

    protected String valueone="";

    protected String valuetwo="";

    protected String operation="";






    please help me..............................

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: Evaluvate when the equal to button is pressed

    Once its set as bellow

    valueone = "1"
    valuetwo = "2"
    operation ="+"

    if(operand.equals("="))
    {
    valuetwo = txt.getText();
    if(operation.equals("+"))
    {
    System.out.println("valueone:= "+valueone+"operation: "+operation+"valuetwo:= "+valuetwo);
    float result = Float.parseFloat(valueone) + Float.parseFloat(valuetwo);
    resetCalculator();
    txt.setText(String.valueOf(result));
    }

    You will see the result as 3 on the screen.
    Thanks,
    Ekta

Similar Threads

  1. How to capture when power button is pressed?
    By qt_chenchen in forum Symbian
    Replies: 11
    Last Post: 2011-04-26, 09:19
  2. QT TextBox after pressed a button
    By JM30 in forum Qt
    Replies: 3
    Last Post: 2010-03-25, 15:37
  3. Keep button pressed (like toggle buttons)
    By pixsta in forum Symbian User Interface
    Replies: 4
    Last Post: 2010-02-16, 06:28
  4. getting ok button pressed
    By csIndia in forum Mobile Java General
    Replies: 4
    Last Post: 2006-08-09, 08:31
  5. Menu only when button pressed
    By donalRok in forum Symbian User Interface
    Replies: 0
    Last Post: 2004-09-29, 09:21

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×