<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                # Java 程序:不使用`sqrt`查找數字的平方根 > 原文: [https://beginnersbook.com/2019/02/java-program-to-find-square-root-of-a-number-without-sqrt/](https://beginnersbook.com/2019/02/java-program-to-find-square-root-of-a-number-without-sqrt/) 找到數字的平方根非常容易,我們可以使用`Math.sqrt()`方法找出任??意數字的平方根。但是在本教程中我們將做一些不同的事情,我們將編寫一個 java 程序來找到沒有`sqrt()`方法的數字的**平方根**。 ## Java 示例:不使用`sqrt()`方法查找平方根 在下面的程序中,我們創建了一個方法`squareRoot()`,在方法中我們編寫了一個方程式,用于查找數字的平方根。對于方程式,我們使用[`while`循環](https://beginnersbook.com/2015/03/do-while-loop-in-java-with-example/)。 ```java package com.beginnersbook; import java.util.Scanner; class JavaExample { public static double squareRoot(int number) { double temp; double sr = number / 2; do { temp = sr; sr = (temp + (number / temp)) / 2; } while ((temp - sr) != 0); return sr; } public static void main(String[] args) { System.out.print("Enter any number:"); Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); scanner.close(); System.out.println("Square root of "+ num+ " is: "+squareRoot(num)); } } ``` **輸出:** ![Java Program to find out the square root of a given number](https://img.kancloud.cn/5f/da/5fda1d1ce9de09d5626a74daafde5dfd_1024x978.jpg) #### 相關的 Java 示例 1. [Java 程序:檢查完美平方數](https://beginnersbook.com/2019/02/java-program-to-check-if-given-number-is-perfect-square/) 2. [Java 程序:打破數字](https://beginnersbook.com/2019/02/java-program-to-break-integer-into-digits/) 3. [Java 程序:查找兩個數字的 GCD](https://beginnersbook.com/2018/09/java-program-to-find-gcd-of-two-numbers/) 4. [Java 程序:顯示斐波那契序列](https://beginnersbook.com/2017/09/java-program-to-display-fibonacci-series-using-loops/)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看