do while 문
do{
}while(조건식); // 선수행 후 조건
do{
value = scan.nextInt(); // Scanner클래스를 이용하여 키보드로 부터 숫자값을 입력받습니다.
System.out.println("입력받은 수 : " + value);
}while(value != 10); // 입력받은 값이 10이 아닐 경우에는 계속 반복합니다.
System.out.println("반복문 종료");
while (조건문) 안의 값이 False 일 때 까지 반복
=> 10이 들어오면 중단
printf
public static void main(String[] args) {
System.out.printf("테스트입니당\n"); // %n
System.out.printf("테스트입니당%n");
System.out.printf("%d %x %o %c\n", 100, 100, 100, 100);
System.out.printf("%d %1$x %1$o %1$c\n", 100);
System.out.printf("%c %c %c %c\n", '가', 'A', '!', '3');
System.out.printf("%b\n", true);
System.out.printf("%f %e\n", 100.0, 100.0);
System.out.printf("%.2f\n", 123.5678);
System.out.printf("|%s|\n", "자바");
System.out.printf("|%10s|\n", "자바");
System.out.printf("|%-10s|\n", "자바");
System.out.printf("%,d원\n", 1000000);
}
난수 추출 Math 클래스 활용
1<= x <= max 사이의 난수추출
ex) 1~9 사이 난수 추출
(int)(Math.random()*9)+1;
ex)
min<= x <= max 사이의 난수추출
int x = (int)(Math.random() * (10 - 5 + 1)) + 5;