计算圆柱体的体积。圆周率为3.14,当我们输入半径r和高h时,计算并输出体积v。

代码:

 1 import java.util.*;
 2 public class Main {
 3     public static void main (String [] args) {
 4         Scanner s=new Scanner(System.in);
 5         double r=s.nextInt();
 6         double h=s.nextInt();
 7         double v=0;
 8         v=3.14*r*r*h;
 9         System.out.println(String.format("%.2f",v));        
10     }
11 }

猜你喜欢

转载自www.cnblogs.com/fandehui/p/11050619.html