코드비교

Old VersionNew Version
1import java.util.Scanner; 1import java.util.Scanner; 
2public class Main { 2public class Main { 
  3static Scanner keyboard=new Scanner(System.in); 
3public static void main(String[] args) { 4public static void main(String[] args) { 
4Scanner sc = new Scanner(System.in); 4String per;
5String a = sc.nextLine(); 5String a,b;
6String c = a,d = a; 6per=keyboard.nextLine();
7if(a.contains("M")) { 7a = " ";
8c = "Mathematics"; 8b = " ";
9} 9if (per.contains("M"))
10else if(a.contains("C")) { 10a="Mathematics";
11c = "Computer Science"; 11else if (per.contains("C"))
12} 12a="Computer Science";
13else if(a.contains("I")) { 13else if (per.contains("I"))
14c = "Information Technology"; 14a="Information Technology";
15} 15if (per.contains("1"))
16if(a.contains("1")) { 16b="Freshman";
17d = "Freshman"; 17else if (per.contains("2"))
18} 18b="Sophomore";
19else if(a.contains("2")) { 19else if (per.contains("3"))
20d = "Sophomore"; 20b="Junior";
21} 21else if (per.contains("4"))
22else if(a.contains("3")) { 22b="Senior";
23d = "Junior"; 23System.out.println(a+" "+b);
24}   
25else if(a.contains("4")) {   
26d = "Senior";   
27}   
28System.out.println(c + " " + d);   
29} 25} 
30} 26} 
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.nextLine();
String c = a,d = a;
if(a.contains("M")) {
c = "Mathematics";
}
else if(a.contains("C")) {
c = "Computer Science";
}
else if(a.contains("I")) {
c = "Information Technology";
}
if(a.contains("1")) {
d = "Freshman";
}
else if(a.contains("2")) {
d = "Sophomore";
}
else if(a.contains("3")) {
d = "Junior";
}
else if(a.contains("4")) {
d = "Senior";
}
System.out.println(c + " " + d);
}
}
import java.util.Scanner;
public class Main {
static Scanner keyboard=new Scanner(System.in);
public static void main(String[] args) {
String per;
String a,b;
per=keyboard.nextLine();
a = " ";
b = " ";
if (per.contains("M"))
a="Mathematics";
else if (per.contains("C"))
a="Computer Science";
else if (per.contains("I"))
a="Information Technology";
if (per.contains("1"))
b="Freshman";
else if (per.contains("2"))
b="Sophomore";
else if (per.contains("3"))
b="Junior";
else if (per.contains("4"))
b="Senior";
System.out.println(a+" "+b);
}
}