내가 생각했을때 문제에서 원하는부분
The first three lines of input describe the scoring of the Apples, and the next three lines of input describe the scoring of the Bananas.
For each team, the first line contains the number of successful 3-point shots, the second line contains the number of successful 2-point field goals, and the third line contains the number of successful 1-point free throws.
Each number will be an integer between 0 and 100, inclusive.
The output will be a single character.
If the Apples scored more points than the Bananas, output 'A'.
If the Bananas scored more points than the Apples, output 'B'.
Otherwise, output 'T', to indicate a tie.
내가 이 문제를 보고 생각해본 부분
BufferedReader를 사용하여 입력을 받는다.
사과 팀과 바나나 팀의 각각 3점, 2점, 1점 슛의 성공 개수를 입력받는다.
각 팀의 총 점수를 계산한다.
점수를 비교하여 승자 또는 무승부를 출력한다.
코드로 구현
package baekjoon.baekjoon_26;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// 백준 17009번 문제
public class Main908 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// 사과 팀 점수 입력
int apples3 = Integer.parseInt(br.readLine());
int apples2 = Integer.parseInt(br.readLine());
int apples1 = Integer.parseInt(br.readLine());
// 바나나 팀 점수 입력
int bananas3 = Integer.parseInt(br.readLine());
int bananas2 = Integer.parseInt(br.readLine());
int bananas1 = Integer.parseInt(br.readLine());
// 점수 계산
int appleScore = apples3 * 3 + apples2 * 2 + apples1 * 1;
int bananaScore = bananas3 * 3 + bananas2 * 2 + bananas1 * 1;
// 결과 출력
if(appleScore > bananaScore) {
System.out.println('A');
} else if(bananaScore > appleScore) {
System.out.println('B');
} else {
System.out.println('T');
}
br.close();
}
}
코드와 설명이 부족할수 있습니다. 코드를 보시고 문제가 있거나 코드 개선이 필요한 부분이 있다면 댓글로 말해주시면 감사한 마음으로 참고해 코드를 수정 하겠습니다.