import java.util.Scanner;
import java.text.DecimalFormat;
public class Main {
public static void main(String[] args) {
float R;
float L;
Scanner scan = new Scanner(System.in);
R = scan.nextFloat();
L = scan.nextFloat();
float A = (float) (R * R * 3.14159);
float V = (float) A* L;
DecimalFormat form = new DecimalFormat(".#");
String str1 = form.format(A);
String str2 = form.format(V);
System.out.println(str1);
System.out.println(str2);
scan.close();
}
}
sample 돌려보면
95.5
1140.4
가 나옵니다
뒷자리가 궁금해서 .## 해보니
95.03
1140.4
가 출력됩니다
어디서 틀린 걸까요?ㅜㅜ