1. Download our Official Android App: Forums for Android!

Apps need help on division and displaying the value

Discussion in 'Android Development' started by currycrab, Sep 15, 2011.

  1. currycrab

    currycrab Member
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    31
    Joined:
    Sep 11, 2011

    Sep 11, 2011
    31
    0
    15
    programming student
    somewhere
    when i press calculate. it crash. it looks like there is some problem displaying the result of the division. hope anyone who encountered this problem can help me. thanks alot in advance.


    Code (Text):
    1. protected void showResult(Editable first, Editable second, Editable third,
    2.                               Editable forth, Editable fifth, Editable sixth)
    3.     {
    4.     float num1 = Float.parseFloat(first.toString());
    5.     float num2 = Float.parseFloat(second.toString());
    6.     float num3 = Float.parseFloat(third.toString());
    7.     float num4 = Float.parseFloat(forth.toString());
    8.     float num5 = Float.parseFloat(fifth.toString());
    9.     float num6 = Float.parseFloat(sixth.toString());
    10.     float resultModuleCredits = num1 + num2 + num3;
    11.     float resultGPA = num4 + num5 + num6;
    12.     double result = (resultModuleCredits * resultGPA)/resultModuleCredits;
    13.     Result.setText(String.valueOf(result));
    14.  
    15.  
    16.     }
     

    Advertisement

  2. jonbonazza

    jonbonazza Android Expert
    Rank:
    None
    Points:
    163
    Posts:
    1,930
    Joined:
    Jul 13, 2010

    Jul 13, 2010
    1,930
    457
    163
    Male
    Can we see some logcat output?
     
  3. currycrab

    currycrab Member
    Thread Starter
    Rank:
    None
    Points:
    15
    Posts:
    31
    Joined:
    Sep 11, 2011

    Sep 11, 2011
    31
    0
    15
    programming student
    somewhere
    thanks bro. manage to solved it. im blinded =.= because the value in the text field is empty hence the application crashed thanks.
     

Share This Page

Loading...