Wrong Answer 질문 있습니다!

SeanYi Reply 6 years 33 weeks ago
안녕하세요. 프로그램을 작성했을 때 문제가 발견 되는 거 같지는 않은데 wrong answer가 뜨고 어디서 잘못 됐는지 잘 모르겠습니다. 제가 작성한 코드입니다: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); double radius = input.nextDouble(); double length = input.nextDouble(); while ((radius > 1000) || (radius < 1)) { radius = input.nextDouble(); } while ((length > 1000) || (length < 1)) { length = input.nextDouble(); } double area = (radius * radius) * 3.14159; double volume = area * length; System.out.printf("%.1f\n", area); System.out.printf("%.1f\n", volume); } }
onacloud Reply 6 years 33 weeks ago
%.1f 는 반올림이기 때문에 버림하는 코드를 추가해야 합니다.