# 연습문제: 메소드
---
<div class="embed-responsive embed-responsive-16by9">
<iframe src="https://www.youtube.com/embed/00Hl7WwYeFY" frameborder="0" allowfullscreen></iframe>
</div>
## 주사위 게임
부족한 용돈을 채우기위해 도박에 손을 대고만 야바위 학생. 주사위를 던져 나온 눈의 수만큼 달라를 획득하는 불법 도박사이트에 접속하는데..
참가비용 18달라에 주사위를 5번 던질 수 있을 때, 돈을 얼만큼 이득(또는 손해) 보았는지 계산해주세요.
**요구사항**
+ Math.random() 메소드를 사용하여 1 과 6 사이의 숫자를 반환하는 dice() 메소드를 구현할 것.
**기본코드**
```
class DiceGame {
public static int dice() {
// 해당 메소드를 구현하세요.
return 0;
}
public static void main(String[] args) {
// 주사위 던지기 5번 시도
double earnings = dice() + dice() + dice() + dice() + dice(); // 획득자금($)
System.out.println("획득: $ " + earnings);
// 이익 = 획득자금 - 참가비용
double profit = earnings - 18.0;
System.out.println("손익: $ " + profit);
}
}
```
**출력 예**
```
획득: $ 21.0
손익: $ 3.0
```