/** A class to calculate student grades. */
public class Grades {
  
  /** 
   * Display whether the given numeric grade is
   * a passing or failing grade.
   */ 
  public static void passFail(int g) {
// first try:
//    if (g < 50 && g >= 0) {
//      System.out.println("You Failed!");
//    } else { // g>=50  or g<0
//      if (g <= 100 && g >= 50){
//        System.out.println("You Passed!");
//      } else {
//        System.out.println("Invalid Grade!");
//      }

    
// another way to do it!    
//    if (g >= 50 && g <= 100) {
//      System.out.println("You Passed!");
//    } else if (g < 0 || g > 100) {
//      System.out.println("Invalid Grade!");
//    } else {  
//      System.out.println("You Failed!");
//    }
    
    // a better way (more readable to a human!)    
    if(g < 0 || g > 100) {
      System.out.println("Invalid Grade!");
    } else if (g >= 50) {
      System.out.println("You Passed!");
    } else {
      System.out.println("You Failed!");
    }
  }
  
  /**
   * Display the letter grade for the given
   * numeric grade g.  Assume the value of
   * g is between 0 and 100. So, we don't need
   * to check for values <0 or >100
   */ 
  public static void letterGrade(int g) {
    // many different ways to do this... here is one we did in class:
    if (g < 50) {
      System.out.println("F");
    } else if (g < 60) {
      System.out.println("D");
    } else if (g < 70) {
      System.out.println("C");
    } else if (g < 80) {
      System.out.println("B");
    } else if (g < 90) {
      System.out.println("A");
    } else {
      System.out.println("A+");
    }
    
// here is another one...    
//    if (g >= 80) { // "nested" if-statements!
//      if (g >= 90) {  // if the student has an A+
//        System.out.print("A+");
//      } else {
//        System.out.print("A");
//      }
//    } else if (g >= 70) {    
//      // if this code is executed, then
//      // g < 80 and g >= 70.
//      System.out.println("B");
//    } else if (g >= 60) {
//      // if this is executed, then
//      // g < 80, g < 70 and g >= 60.
//      System.out.println("C");
//    } else if (g >= 50) {
//      // if this is executed, then
//      // g < 80, g < 70, g < 60 and g >= 50.
//      System.out.println("D");
//    } else {
//      // the default case
//      System.out.println("F");
//    }
//    
  }
}