programmingex4 18 java

Solutions on MaxInterview for programmingex4 18 java by the best coders in the world

showing results for - "programmingex4 18 java"
Jonathan
18 Jan 2018
1import java.util.Scanner;
2 
3public class ProgrammingEx4_18 {
4 
5 public static void main(String[] args) {
6 
7  Scanner input = new Scanner(System.in);
8  System.out.print("Enter two characters:");
9  String in = input.nextLine();
10 
11  char major = in.charAt(0);
12  char level = in.charAt(1);
13 
14  String sMajor = "";
15  String sLevel = "";
16 
17  switch (major) {
18  case 'M':
19   sMajor = "Mathematics";
20   break;
21 
22  case 'C':
23   sMajor = "Computer Science";
24   break;
25 
26  case 'I':
27   sMajor = "Information Technology";
28   break;
29 
30  default:
31   System.out.println("Invalid input");
32   System.exit(0);
33   break;
34  }
35 
36  switch (level) {
37  case '1':
38   sLevel = "freshman";
39   break;
40 
41  case '2':
42   sLevel = "sophomore";
43   break;
44 
45  case '3':
46   sLevel = "junior";
47   break;
48 
49  case '4':
50   sLevel = "senior";
51   break;
52 
53  default:
54   System.out.println("Invalid input");
55   System.exit(0);
56   break;
57  }
58  System.out.println(sMajor + " " + sLevel);
59 }
60}
61
similar questions
queries leading to this page
programmingex4 18 java