1에서부터 6까지의 눈을 가진 3개의 주사위를 던져서 다음과 같은 규칙에 따라 상금을 받는 게임이 있다.
1. 같은 눈이 3개가 나오면 10,000원+(같은 눈)×1,000원의 상금을 받게 된다.
2. 같은 눈이 2개만 나오는 경우에는 1,000원+(같은 눈)×100원의 상금을 받게 된다.
3. 모두 다른 눈이 나오는 경우에는 (그 중 가장 큰 눈)×100원의 상금을 받게 된다.
예를 들어, 3개의 눈 3, 3, 6이 주어지면 상금은 1,000+3×100으로 계산되어 1,300원을 받게 된다. 또 3개의 눈이 2, 2, 2로 주어지면 10,000+2×1,000 으로 계산되어 12,000원을 받게 된다. 3개의 눈이 6, 2, 5로 주어지면 그중 가장 큰 값이 6이므로 6×100으로 계산되어 600원을 상금으로 받게 된다.
3개 주사위의 나온 눈이 주어질 때, 상금
을 계산하는 프로그램을 작성 하시오.
첫째 줄에 3개의 눈
이 빈칸을 사이에 두고 각각 주어진다.
첫째 줄에 게임의 상금
을 출력 한다.
3 3 6
1300
2 2 2
12000
6 2 5
600
Olympiad > 한국정보올림피아드 > 한국정보올림피아드시․도지역본선 > 지역본선 2010 > 중등부 1번
-잘못된 데이터를 찾은 사람: sait2000
-데이터를 추가한 사람: tkdring3
import java.util.Scanner;
public class Code2480 {
public static void main(String[] args) {
int first,second,third; //save dice number
int total=0; //price
int max=0;
Scanner scanner=new Scanner(System.in);
first=scanner.nextInt();
second=scanner.nextInt();
third=scanner.nextInt();
if((first==second)&&(second==third)) { //and
total=10000+first*1000;
}
else if ((first==second)||(second==third)||(first==third)) {
if(first==second) {
total=1000+first*100;
}
else if(second==third) {
total=1000+second*100;
}
else if(first==third) {
total=1000+first*100;
}
}
else {
if(first>third) {
max=first>second ? first:second;
}
else if(second>third) {
max=first>second ? first:second;
}
else if(third>first) {
max=third>second ? third:second;
}
total=max*100;
}
System.out.println(total);
}
}
조건문도 완료