I want to create app. I have attached the layout.
HTML:
<p><b>My codes are:</b></p>
Java:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//This is where my codes will go
//linking EditText widgets
final EditText eAss1 = (EditText)findViewById(R.id.ass1);
final EditText eAss2 = (EditText)findViewById(R.id.ass2);
final EditText eAss3 = (EditText)findViewById(R.id.Ass3);
final EditText eExamMark = (EditText)findViewById(R.id.ExamMark);
//linking TextView widgets
final TextView errorMessage = (TextView)findViewById(R.id.errorView);
final TextView efinalPerce = (TextView)findViewById(R.id.finalPerc);
final TextView efailOrPass = (TextView)findViewById(R.id.failOrPass);
//linking the button widget
Button but1 = (Button)findViewById(R.id.btnCalc);
but1.setOnClickListener(new OnClickListener(){
public void onClick(View v){
//this is where my codes for calculations will go
double eAss1Val = Double.valueOf(eAss1.getText());
double eAss2Val = Double.valueOf(eAss2.getText());
double eAss3Val = Double.valueOf(eAss3.getText());
double eExamMark = Double.valueOf(eExamMark);
double yearMark = eAss1Val * 0.15 + eAss2Val * 0.35 + eAss3Val * 0.5;
double finalMark = yearMark * .49 + eExamMark * .51;
}//end of onClick
});
HTML:
<p>But am getting error saying</p>
<p>The method valueOf(string) in the type double is not applicable for the arguments(Editable)
<p>examMark.getText() cannot invoke getText() on the primitive type double</p>
<p>Please, someone kindly assist me on how to do the calculation of the layout I attached. </p?
<p>Thanks</p>