java中方法的使用
2018-05-14 11:37 yelena 阅读(123) 评论(0) 编辑 收藏 举报import java.util.Scanner; class Demo01 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); /*System.out.println("输入"); a = sc.nextInt(); System.out.println("输入"); b = sc.nextInt(); int s = sum(a,b); System.out.println(s);*/ System.out.println("输入"); int c = sc.nextInt(); double mj = mj(c); System.out.print(mj); } //用于求和的方法 public static int sum(int a,int b){ int sum = a + b; return sum; } //求园的面积的方法 public static double mj(int c){ double mj = c*c * Math.PI; return mj; } }