lundi 2 novembre 2015

My 'if' statement is not working properly

I have an assignment where I am supposed to determine whether the average of three values is 'above average' or 'below average'. For some reason whatever is input will always be above average as the result. Here is my code below, thank you for any help!

import java.util.Scanner;

class Lesson_12_Activity_One {
public static void main(String[] args)
 {
 Scanner scan = new Scanner(System.in);

 System.out.println("Enter three values");
 double x = scan.nextDouble();
 double y = scan.nextDouble();
 double z = scan.nextDouble();
 double t = (double)Math.round(100*((x+y+z)/3));

 System.out.print("The average is " + (t/100));

 if(t >= 89.5)     
   System.out.print(" ABOVE AVERAGE");
 else
   System.out.print(" BELOW AVERAGE");    
}

}

Aucun commentaire:

Enregistrer un commentaire