Scanner sc = new Scanner(System.in);
int score;
score = sc.nextInt();
score = (score / 10)* 10;
switch (score) {
case 100:
System.out.println("A");
break;
case 90:
System.out.println("A");
break;
case 80:
System.out.println("B");
break;
case 70:
System.out.println("C");
break;
default:
System.out.println("F");
break;
}
if
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
if(i > 100) {
System.out.println(i+ " 는 백보다 크다.");
}
else if (i == 100) {
System.out.println(i+ " 는 백과 같다.");
}
else {
System.out.println(i+ " 는 백보다 작다.");
}
입력하는 방법
cf. 출력하는 방법
System.out.print();
=> 반복 설정을 하지 않아서 입력은 일 회만 가능하다.
🟡 단축키
command + /
: block 주석 설정control + space
: tab키 처럼 자동 완성if 와 switch
switch
정형화된 조건 유형에 따를 경우
switch
eg) 서양에서 월을 표현할 때. 학생들의 성적
int
: 정수 타입이라서 뒤의 소수를 알아서 제거한다.if
String은 객체이기 때문에
String == String
어렵다.String 내장 매소드
.equals()
를 이용해야 한다.🌟 String 자체 내장 매소드는 자주 사용하기 때문에 내장 매소드를 전체 공부하는 게 좋다.
반복문
for
,while
,do~while
,iterator
list를 iterator로 하면 편하다.
while
위의 경우에는
i % 2 != 0
일 때,i++
가 적용이 안되서... while 무한 반복🌟
i++
vs++i
✔️과제는 메일로
다음 수업은 9월 23일 목요일