Hey guys. I am trying to write a program that approximates certain values to a grade, but whenever I put a value below 4 I always get an output of A+. What's am I missing?
public class Grade { private double grade; public Grade (double g) { grade = g; } public void getNumericCode() { if (grade > 4) { System.out.println("You are smart, but not THAT smart!"); } else if (grade <= 4) { System.out.println("A +"); } else if (grade <= 3.8) { System.out.println("A"); } else if (grade <= 3.2) { System.out.println("A -"); } else if (grade <= 3) { System.out.println("B +"); } else if (grade <= 2.8) { System.out.println("B"); } else if (grade <= 2.2) { System.out.println("B -"); } else if (grade <= 2) { System.out.println("C +"); } else if (grade <= 1.8) { System.out.println("C"); } else if(grade <= 1.2) { System.out.println("C -"); } else if (grade <= 1) { System.out.println("D +"); } else if (grade <= 0.8) { System.out.println("D"); } else if (grade <= 0.2) { System.out.println("D -"); } else if (grade >= 0) { System.out.println("F"); } else { System.out.println("Not a valid grade."); } } }