๐ Switch๋ฌธ
String yourPosition = userInput.nextLine(); //์
๋ ฅ๋ฐ๊ธฐ
switch (yourPosition) {
case "Senior" : // Senior์ผ ๊ฒฝ์ฐ
System.out.println("700๋ง์");
break;
case "Junior" : // Junior ๋๋ Manager์ผ ๊ฒฝ์ฐ
case "Manager" : // ์คํ๋ฌธ์ด ๊ฐ์ผ๋ฉด ์ด๋ ๊ฒ ์์ฑ ๊ฐ๋ฅ
System.out.println("500๋ง์");
break;
default:
System.out.println("300๋ง์");
break;
int, char ํ์ ๋ณ์๊ฐ ๊ฐ๋ฅํ๊ณ ์๋ฐ 7๋ถํฐ ์คํธ๋ง ํ์ ๋ณ์๋ ๊ฐ๋ฅํ๋ค.
String[] positionList = {"Manager", "Senior", "Junior"};
String yourPosition = userInput.nextLine(); // ์
๋ ฅ ๋ฐ๊ธฐ
switch (yourPosition) {
case "Senior" -> System.out.println("700๋ง์");
case "Junior", "Manager" -> System.out.println("500๋ง์");
}
์๋ฐ 14 ์ด์๋ถํฐ ๋๋ค ์คํ์ผ ๊ตฌ๋ฌธ์ด ๊ฐ๋ฅํ๋ค.