코드비교

Old VersionNew Version
1import java.util.*; 1import java.util.*; 
2public class Main { 2class Main {
3public static void main(String[] args) { 3public static void main(String[] args) { 
4Scanner sc = new Scanner(System.in); 4Scanner sc = new Scanner(System.in); 
5String a = sc.next(); 5String s=sc.nextLine();
6if(a.charAt(0) == 'M') { 6char major=s.charAt(0);
7System.out.print("Mathematics "); 7char c=s.charAt(1);
   8switch (major) {
   9case 'M':
   10System.out.printf("Mathematics ");
   11break;
   12case 'C':
   13System.out.printf("Computer Science ");
   14break;
   15case 'I':
   16System.out.printf("Information Technology ");
   17break;
8} 18} 
9else if(a.charAt(0) == 'C') { 9switch (c) {
10System.out.print("Computer Science ");   
11}   
12else {   
13System.out.print("Information Technology ");   
14}   
15char aa = a.charAt(1);   
16switch(aa) {   
17case '1': 20case '1': 
18System.out.println("Freshman"); 18System.out.printf("Freshman");
19break; 22break; 
20case '2': 23case '2': 
21System.out.println("Sophomore"); 21System.out.printf("Sophomore");
22break; 25break; 
23case '3': 26case '3': 
24System.out.println("Junior"); 24System.out.printf("Junior");
25break; 28break; 
26case '4': 29case '4': 
27System.out.println("Senior"); 27System.out.printf("Senior");
28break; 31break; 
29} 32} 
30} 33} 
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.next();
if(a.charAt(0) == 'M') {
System.out.print("Mathematics ");
}
else if(a.charAt(0) == 'C') {
System.out.print("Computer Science ");
}
else {
System.out.print("Information Technology ");
}
char aa = a.charAt(1);
switch(aa) {
case '1':
System.out.println("Freshman");
break;
case '2':
System.out.println("Sophomore");
break;
case '3':
System.out.println("Junior");
break;
case '4':
System.out.println("Senior");
break;
}
}
}
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
char major=s.charAt(0);
char c=s.charAt(1);
switch (major) {
case 'M':
System.out.printf("Mathematics ");
break;
case 'C':
System.out.printf("Computer Science ");
break;
case 'I':
System.out.printf("Information Technology ");
break;
}
switch (c) {
case '1':
System.out.printf("Freshman");
break;
case '2':
System.out.printf("Sophomore");
break;
case '3':
System.out.printf("Junior");
break;
case '4':
System.out.printf("Senior");
break;
}
}
}