• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to do calculations?

Leye

Lurker
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.
 

Attachments

  • WP_20160722_01_40_42_Pro.jpg
    WP_20160722_01_40_42_Pro.jpg
    470.4 KB · Views: 74
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:
Double eAss1Val = Double.valueOf(eAss1.getText());
Double eAss2Val = Double.valueOf(eAss2.getText());
Double eAss3Val = Double.valueOf(eAss3.getText());

Double yearMark = eAssVal1 * 0.15 + eAssVal2 * 0.35 + eAssVal3 * 0.5;
 
@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?
 
Back
Top Bottom