TizzyT

Branching[CODE] -TizzyT

Feb 9th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.72 KB | None | 0 0
  1. package branching;
  2. import java.util.Scanner;
  3.  
  4. public class Program {
  5.     // Enum to store levels of honors
  6.     public enum Honors { SUMMA_CUM_LAUDE, MAGNA_CUM_LAUDE, CUM_LAUDE, NO_HONORS }
  7.     // Enum to store graduation status
  8.     public enum Graduates { ELIGIBLE, NON_ELIGIBLE }
  9.  
  10.     public static void main(String[] args) {
  11.         // Scanner object to get inputs
  12.         Scanner Input = new Scanner(System.in);
  13.        
  14.         // Ask user what their name is
  15.         System.out.println("Enter your name:");
  16.         // String to store users name
  17.         String Name = Input.nextLine();
  18.  
  19.         // Ask user what their GPA is
  20.         System.out.println("Enter your GPA:");
  21.         // double to store users input GPA
  22.         double GPA = Input.nextDouble();
  23.  
  24.         // Closed the input stream
  25.         Input.close();
  26.        
  27.         // Creates a new Honors, set to SUMMA_CUM_LAUDE
  28.         Honors HonorLvL = Honors.SUMMA_CUM_LAUDE;
  29.  
  30.         // Creates a new Graduates, set to ELIGIBLE as default
  31.         Graduates Graduate = Graduates.ELIGIBLE;
  32.  
  33.         // if GPA is lower than 3.8 set HonorLvL to MANGA_CUM_LAUDE
  34.         if (GPA < 3.8) HonorLvL = Honors.MAGNA_CUM_LAUDE;
  35.         // if GPA is lower than 3.6 set HonorLvL to CUM_LAUDE
  36.         if (GPA < 3.6) HonorLvL = Honors.CUM_LAUDE;
  37.         // if GPA is lower than 3.2 set HonorLvL to NO_HONORS
  38.         if (GPA < 3.2) HonorLvL = Honors.NO_HONORS;
  39.         // if GPA is lower than 2.0 set graduates to NON_ELIGIBLE
  40.         if (GPA < 2.0) Graduate = Graduates.NON_ELIGIBLE;
  41.  
  42.         // Outputs the students name
  43.         System.out.println("Name:\t\t\t" + Name);
  44.         // Outputs the graduation status
  45.         System.out.println("Graduation Status:\t" + Graduate);
  46.         // Outputs the honor level
  47.         System.out.println("Honor level:\t\t" + HonorLvL);
  48.     }
  49. }
Add Comment
Please, Sign In to add comment