mercredi 9 septembre 2015

If statement not working correctly javva

I am trying to finish my java assignment for grading a class and am having issues with the if statement. The statement was given to us generally in the problem and I have tried to adapt it to java but it obviously does not work.

  grade = 0.5f * ex + 0.1f *mid + 0.1f * A + bonus + Jb;
  if (ex < 40) 
     grade += 0.3 * ex; 
  else
     if (ex > 50)
        grade += 0.2 * Math.max(ex, mid) + 0.1 * Math.max(ex, A);
  else
     grade += 0.02 * ((ex - 40) * Math.max(ex, mid) + (50 - ex) * ex)
     + 0.01 * ((ex - 40) * Math.max(ex, A) + (50 - ex) * ex);
  if (mid < 40)
     grade = Math.min(grade, mid);
  if (A < 50)
     grade = Math.min(grade, A);

The if statement does not seem to function correctly as even when the value of mid or ex is below 40 it does not trigger those parts of the if statement ant the student still gets a good grade in the course. I attempted to print the value after the first if statement and even at that point the value isn't equal to the value of 0.3*ex so I am really at a loss for what is going on.

Aucun commentaire:

Enregistrer un commentaire