Board logo

標題: 函式的建立與執行 (二) [打印本頁]

作者: tonyh    時間: 2012-12-15 17:24     標題: 函式的建立與執行 (二)

建立並執行一個專門計算三角形面積的函式.
  1. public class ch50
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         System.out.println(triangle(3,5));
  6.     }

  7.     public static float triangle(float x, float y)
  8.     {
  9.         return x*y/2;
  10.     }
  11. }
複製代碼

作者: t2364705    時間: 2012-12-15 17:26

  1. public class ch50
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         System.out.println(triangle(3,5));
  6.     }

  7.     public static float triangle(float x, float y)
  8.     {
  9.         return x*y/2;
  10.     }
  11. }
複製代碼

作者: lon    時間: 2012-12-15 17:27

  1. public class ch50{
  2.   public static void main(String args[]){
  3.     System.out.println(triangle(3,5));
  4.     }
  5.   public static float triangle(float x, float y){
  6.     return x*y/2
  7.   }
  8. }
複製代碼

作者: 粘靖瑜    時間: 2012-12-15 17:27

  1. public class ch50
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         System.out.println(triangle(3,5));
  6.     }

  7.     public static float triangle(float x, float y)
  8.     {
  9.         return x*y/2;
  10.     }
  11. }
複製代碼

作者: 尤泓鈞    時間: 2012-12-15 17:29

  1. public class ch50
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         System.out.println(triangle(3,5));
  6.     }
  7.     public static float triangle(float x, float y)
  8.     {
  9.         return x*y/2;
  10.     }
  11. }
複製代碼

作者: 蔡昀佑    時間: 2012-12-15 17:29

  1. public class ch50
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         System.out.println(triangle(3,5));
  6.     }

  7.     public static float triangle(float x, float y)
  8.     {
  9.         return x*y/2;
  10.     }
  11. }
複製代碼

作者: t3742238    時間: 2012-12-15 17:31

  1. public class ch50
  2. {
  3.     public static void main(String args[])
  4.     {
  5.       System.out.println(triangle(3,5));
  6.     }

  7.     public static float triangle(float x ,float y)
  8.     {
  9.       return x*y/2;

  10.     }
  11. }
複製代碼

作者: 劉漢文    時間: 2012-12-15 17:31

  1. public class ch50
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         System.out.println(triangle(3,5));
  6.     }

  7.     public static float triangle(float x, float y)
  8.     {
  9.         return x*y/2;
  10.     }
  11. }
複製代碼

作者: 黃博鴻    時間: 2012-12-17 18:12

  1. import java.util.Arrays;
  2. public class ch49
  3. {
  4.     public static void main(String args[])
  5.     {
  6.       System.out.println(triangle(3,5));
  7.     }
  8.     public static float triangle(float a,float b)
  9.     {
  10.         return a*b/2;
  11.     }
  12. }
複製代碼

作者: 粘靖瑜    時間: 2013-1-19 10:06

  1. public class ch50
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         System.out.println(triangle(3,5));
  6.     }

  7.     public static float triangle(float a, float b)
  8.     {
  9.         return a*b/2;
  10.     }
  11. }
複製代碼





歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/) Powered by Discuz! 7.2