fork download
  1. class Renshu5_4 {
  2. public static void main(String[] args) {
  3. System.out.println("求める三角形の面積は、" + calcTriangleArea(10.0, 5.0) + "平方cm");
  4. System.out.println("求める円の面積は、" + calcCircleArea(5.0) + "平方cm");
  5. }
  6.  
  7. public static double calcTriangleArea(double bottom, double height) { // cm
  8. double area = bottom * height / 2;
  9. return area;
  10. }
  11.  
  12. public static double calcCircleArea(double radius) { // cm
  13. double area = radius * radius * 3.14;
  14. return area;
  15. }
  16. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
求める三角形の面積は、25.0平方cm
求める円の面積は、78.5平方cm