# Random 클래스 ## 문제 `Random` 클래스를 활용하여 출력 예와 같은 난수를 생성하시오. ## 자바 API 문서 + https://docs.oracle.com/javase/8/docs/api/ ## 뼈대코드 ``` import java.util.Random; // Random 클래스 불러오기. public class Main { public static void main(String[] args) { Random rand = new Random(); // 난수 생성 int a = 0; /* 1. 임의의 정수를 생성하시오. */ int b = 0; /* 2. 0~30 사이의 정수를 생성하시오 */ double c = 0; /* 3. 임의의 실수를 생성하시오. */ boolean d = false; /* 4. 임의의 참/거짓을 생성하시오. */ // 출력 System.out.printf("nextInt(): %d\n", a); System.out.printf("nextInt(30): %d\n", b); System.out.printf("nextDouble(): %f\n", c); System.out.printf("nextBoolean(): %s\n", d); } } ``` ## 출력 예 ``` nextInt(): 1788063462 nextInt(30): 3 nextDouble(): 0.392243 nextBoolean(): true ```
관련 강의로 이동

코드: java 1.8

public class Main { public static void main(String[] args) { } }

입력

정답이 궁금하다면? 코드를 제출해보세요!