프로그래밍/자바의정석_4_연습문제
[4-7] Math.random()을 이용해서 1부터 6사이의 임의의 정수를 변수 value에 저장하는 코드를 완성하라. (1)에 알맞은 코드를 넣으시오.
므시칸곰틔군
2014. 8. 5. 15:09
public class ex_007 {
// [4-7] Math.random()을 이용해서 1부터 6사이의 임의의 정수를 변수 value에 저장하는 코드를 완성하라. (1)에 알맞은 코드를 넣으시오.
// [연습문제]/ch4/Exercise4_7.java
// class Exercise4_7 {
// public static void main(String[] args) {
// int value = (1);
// System.out.println("value:"+value);
// }
// }
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int value = (int) (Math.random() * 6) + 1;
System.out.println("value:" + value);
}
}