[Snow-ball]프로그래밍(컴퓨터)/java
[Java] 3명이서 주사위를 굴려서 가장 큰 숫자가 나온 사람이 이기는 게임
Snow-ball
2021. 1. 5. 09:51
반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import java.util.Random;
public class HomeWork3 {
public static void main(String[] args) {
//주사위 3 개를 굴려서 가장 큰 숫자가 나온 사람이 이기게 만들자!
//사람은 총 3명(A, B, C)가 있다고 가정한다.
Random rand1 = new Random();
int A = rand1.nextInt(6) + 1;
System.out.println("A 주사위값 = " + A);
Random rand2 = new Random();
int B = rand2.nextInt(6) + 1;
System.out.println("B 주사위값 = " + B);
Random rand3 = new Random();
int C = rand3.nextInt(6) + 1;
System.out.println("C 주사위값 = " + C);
if(A > B && A > C){
System.out.println("A가 승리");
} else if(B > A && B > C){
System.out.println("B가 승리");
} else if(C > A && C > B){
System.out.println("C가 승리");
} else{
System.out.println("제일 높은 점수가 2명이상 입니다. 다시 던지시오!");
}
}
}
|
cs |
베타존 : 네이버쇼핑 스마트스토어
나를 꾸미다 - 인테리어소품 베타존
smartstore.naver.com
반응형