Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package branching;
- import java.util.Scanner;
- public class Program {
- // Enum to store levels of honors
- public enum Honors { SUMMA_CUM_LAUDE, MAGNA_CUM_LAUDE, CUM_LAUDE, NO_HONORS }
- // Enum to store graduation status
- public enum Graduates { ELIGIBLE, NON_ELIGIBLE }
- public static void main(String[] args) {
- // Scanner object to get inputs
- Scanner Input = new Scanner(System.in);
- // Ask user what their name is
- System.out.println("Enter your name:");
- // String to store users name
- String Name = Input.nextLine();
- // Ask user what their GPA is
- System.out.println("Enter your GPA:");
- // double to store users input GPA
- double GPA = Input.nextDouble();
- // Closed the input stream
- Input.close();
- // Creates a new Honors, set to SUMMA_CUM_LAUDE
- Honors HonorLvL = Honors.SUMMA_CUM_LAUDE;
- // Creates a new Graduates, set to ELIGIBLE as default
- Graduates Graduate = Graduates.ELIGIBLE;
- // if GPA is lower than 3.8 set HonorLvL to MANGA_CUM_LAUDE
- if (GPA < 3.8) HonorLvL = Honors.MAGNA_CUM_LAUDE;
- // if GPA is lower than 3.6 set HonorLvL to CUM_LAUDE
- if (GPA < 3.6) HonorLvL = Honors.CUM_LAUDE;
- // if GPA is lower than 3.2 set HonorLvL to NO_HONORS
- if (GPA < 3.2) HonorLvL = Honors.NO_HONORS;
- // if GPA is lower than 2.0 set graduates to NON_ELIGIBLE
- if (GPA < 2.0) Graduate = Graduates.NON_ELIGIBLE;
- // Outputs the students name
- System.out.println("Name:\t\t\t" + Name);
- // Outputs the graduation status
- System.out.println("Graduation Status:\t" + Graduate);
- // Outputs the honor level
- System.out.println("Honor level:\t\t" + HonorLvL);
- }
- }
Add Comment
Please, Sign In to add comment