
위 문제는 intValue()를 사용하지 않고도 int로 해결할 수 있다. 하지만 일반적으로 점수는 Double를 쓰므로 Double에서 .intValue() 메서드를 통해서 int형으로 출력을 해주었다.
public class Score {
public static void main(String[] args) {
/* 1. 변수 생성 */
Double math = 96.0;
Double science = 88.0;
Double english = 76.0;
/* 2. 결과 출력 */
System.out.println("수학: " + math.intValue());
System.out.println("과학: " + science.intValue());
System.out.println("영어: " + english.intValue());
}
}
이외에 Double의 메서드는 다음과 같다.
