티스토리 뷰

IT/JAVA

[java] 소수점 자르기

긍정탁 2021. 11. 25. 15:32
import java.io.IOException;
import java.util.*;

public class Main {

public static double w=0;

   public static void main(String[] args) throws IOException {

      Scanner sc = new Scanner(System.in);

          double r = sc.nextInt() ;

      double ret;
          ret= r*r*2;
      
          r = pfm(r);


        //  System.out.println(Math.round(r*1000000)/1000000.0);
        //  System.out.println(Math.round(ret*100)/100.0);
          System.out.println(String.format("%.6f",r));
          System.out.println(String.format("%.6f",ret));

   } // end of Main
   
   public static double pfm(double r){
   
      w = r*r*Math.PI;

          return w;

   }
                 
} // end of class Main
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31