Board logo

標題: pow() 函式 [打印本頁]

作者: tonyh    時間: 2013-1-5 16:57     標題: pow() 函式

利用pow()函式, 來做冪次的運算.
作者: 黃博鴻    時間: 2013-1-5 17:13

  1. import java.lang.Math;
  2. import java.util.Scanner;
  3. public class ch53
  4. {
  5.     public static void main(String args[])
  6.     {
  7.            Scanner input=new Scanner(System.in);
  8.            float x,y;
  9.            System.out.print("底數: ");
  10.            x=input.nextFloat();
  11.            System.out.print("指數: ");
  12.            y=input.nextFloat();
  13.            System.out.print(x+"的"+y+"次方為"+Math.pow(x,y));
  14.     }
  15. }
複製代碼

作者: t2364705    時間: 2013-1-5 17:14

本帖最後由 t2364705 於 2013-1-5 17:22 編輯
  1. import java.lang.Math;
  2. import java.util.Scanner;
  3. public class ch53
  4. {
  5.     public static void main(String args[])
  6.     {
  7.            Scanner input=new Scanner(System.in);
  8.            float x,y;
  9.            System.out.print("請輸入底數: ");
  10.            x=input.nextFloat();
  11.            System.out.print("請輸入指數: ");
  12.            y=input.nextFloat();
  13.            System.out.print(x+"的"+y+"次方為"+Math.pow(x,y));
  14.     }
  15. }
複製代碼

作者: 劉漢文    時間: 2013-1-5 17:14

  1. import java.lang.Math;
  2. import java.util.Scanner;
  3. public class ch53
  4. {
  5.     public static void main(String args[])
  6.     {
  7.            Scanner input=new Scanner(System.in);
  8.            float x,y;
  9.            System.out.print("底數: ");
  10.            x=input.nextFloat();
  11.            System.out.print("指數: ");
  12.            y=input.nextFloat();
  13.            System.out.print(x+"的"+y+"次方為"+Math.pow(x,y));
  14.     }
  15. }
複製代碼

作者: t3742238    時間: 2013-1-5 17:16

  1. import java.lang.Math;
  2. import java.util.Scanner;
  3. public class ch53
  4. {
  5.     public static void main(String args[])
  6.     {
  7.       Scanner scan=new Scanner(System.in);
  8.       float x,y;
  9.       System.out.print("請輸入底數");
  10.       x=scan.nextFloat();
  11.       System.out.print("請輸入指數");
  12.       y=scan.nextFlont();
  13.       System.out.println(x+"的"+y+"次方,值為"+Math.pow(x,y));

  14.     }

  15. }
複製代碼

作者: 尤泓鈞    時間: 2013-1-5 17:17

  1. import java.lang.Math;
  2. import java.util.Scanner;
  3. public class ch53
  4. {
  5.     public static void main(String args[])
  6.     {
  7.            Scanner input=new Scanner(System.in);
  8.            float x,y;
  9.            System.out.print("底數: ");
  10.            x=input.nextFloat();
  11.            System.out.print("指數: ");
  12.            y=input.nextFloat();
  13.            System.out.print(x+"的"+y+"次方為"+Math.pow(x,y));
  14.     }
  15. }
複製代碼

作者: 蔡昀佑    時間: 2013-1-5 17:27

  1. import java.lang.Math;
  2. import java.util.Scanner;
  3. public class ch53
  4. {
  5.     public static void main(String args[])
  6.     {
  7.            Scanner input=new Scanner(System.in);
  8.            float x,y;
  9.            System.out.print("底數: ");
  10.            x=input.nextFloat();
  11.            System.out.print("指數: ");
  12.            y=input.nextFloat();
  13.            System.out.print(x+"的"+y+"次方為"+Math.pow(x,y));
  14.     }
  15. }
複製代碼

作者: lon    時間: 2013-1-5 17:27

  1. import java.lang.*;
  2. import java.util.*;
  3. public class ch53{
  4.   public static void main(String args[]){
  5.     Scanner s=new Scanner(System.in);
  6.     float x,y;
  7.     System.out.print("底數:");
  8.     x=s.nextFloat();
  9.     System.out.print("指數:");
  10.     y=s.nextFloat();
  11.     System.out.println("x的y次方:"+Math.pow(x,y));
  12.   }
  13. }
複製代碼

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

  1. import java.until.Scanner;
  2. public class ch53
  3. {
  4.     public static void main(String args[])
  5.     {
  6.         int x, y;
  7.         Scanner s=new scanner(System.in);
  8.         System.out.print("請輸入底數: ");
  9.         x=s.nextInt();
  10.         System.out.print("請輸入底數: ");
  11.         y=s.nextInt();
  12.         System.out.println(x+"的"+y+"次方,值為"+Math.pow(x,y));
  13.     }
  14. }
複製代碼





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