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

Apps How to do calculations?

Discussion in 'Android Development' started by Leye, Jul 22, 2016.

  1. Leye

    Leye Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jul 22, 2016

    Jul 22, 2016
    4
    0
    5
    Male
    Hello everyone,


    Please, by mercy of God, kindly help me. I will like to create an app that can calculate assignments and final marks as following:


    Field1=Assignment1

    Field2=Assignment2

    Field3=Assignment3

    Field4=Exam marks


    1x button. User will click to do the calculations

    1xText field dispalying the year mark. The user must NOT be able to edit or update this field

    1xText field to display the Final Mark.

    1xText field displaying where the mark is a fail, pass or distinction. Fail is a mark below 50% and distinction a mark above 75%. The user must NOT be able to edit or update this field.


    The calcuation to determine the Year mark is as follow:


    YearMark= Assignment1 x .15 + Assignment2 x .35 + Assignment3 x .50


    The calculation to determine the Final Mark:


    FinalMark = YearMark x .49 + ExamMark x .51



    I created my codes as following, but giving me error:


    final Editext eAss1 = (EditText)findViewById(R.id.ass1)

    final EditTtext eAss2= (EditText)findViewById(R.id.ass2)

    final EditTetext eAss2 = (EditText)findViewById(R.id.ass3)

    final EditTtext eExamMark = (EditText)findViewById(R.id.ExamMark)


    TextView errorMessage = (TextView)findViewById(R.Id.errorMessage)

    TextView finalPerc = (TextView)findViewById(R.Id.finalPerc)

    TextView failOrPass = (TextView)findViewById(R.Id. failOrPass)


    From my above codes. I dont know what to do. To calculate the assignments calculations in my app?

    Please, kindly find the attached to see how my codes were created.

    Please, kindly help me.

    Thank you.
     

    Attached Files:


    Advertisement

  2. Unforgiven

    Unforgiven OK Google
    Moderator
    Rank:
     #1
    Points:
    4,238
    Posts:
    36,325
    Joined:
    Jun 23, 2010

    Jun 23, 2010
    36,325
    42,491
    4,238
    Male
    Douglas, MA
    Application Development thread moved to the Development forum for better exposure.:)
     
  3. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #11
    Points:
    1,988
    Posts:
    7,878
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    7,878
    11,515
    1,988
    Male
    Software developer
    South West of England
    Variables eAss1, eAss2, eAss3 are all of type EditText. You need to get the values from them, convert to Double and then do the multiplication

    Something like this

    Code (Text):
    1.  
    2. Double eAss1Val = Double.valueOf(eAss1.getText());
    3. Double eAss2Val = Double.valueOf(eAss2.getText());
    4. Double eAss3Val = Double.valueOf(eAss3.getText());
    5.  
    6. Double yearMark = eAssVal1 * 0.15 + eAssVal2 * 0.35 + eAssVal3 * 0.5;
    7.  
     
    Unforgiven likes this.
  4. Leye

    Leye Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jul 22, 2016

    Jul 22, 2016
    4
    0
    5
    Male
    @LV426, thanks for your reply. I will do as you said.

    Please, how can I make editText editable?

    I have tried to set it under filed's properties, but could not see where to set it editable or not editable?
     
  5. LV426

    LV426 I say we take off and nuke this place from orbit
    Moderator
    Rank:
     #11
    Points:
    1,988
    Posts:
    7,878
    Joined:
    Oct 16, 2015

    Oct 16, 2015
    7,878
    11,515
    1,988
    Male
    Software developer
    South West of England
  6. Leye

    Leye Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    4
    Joined:
    Jul 22, 2016

    Jul 22, 2016
    4
    0
    5
    Male
    Ok. Thanks.

    I am new to Java and Android. But thanks to you for assisting me. Thank you.
     

Share This Page

Loading...