<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>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # Java 程序:計算三角面積 > 原文: [https://beginnersbook.com/2014/01/java-program-to-calculate-area-of-triangle/](https://beginnersbook.com/2014/01/java-program-to-calculate-area-of-triangle/) 在這里,我們將看到如何計算三角形的面積。我們將看到以下兩個程序: 1)程序 1:提示用戶輸入三角形的基本寬度和高度。 2)程序 2:無用戶交互:程序本身指定了寬度和高度。 **計劃 1:** ```java /** * @author: BeginnersBook.com * @description: Program to Calculate area of Triangle in Java * with user interaction. Program will prompt user to enter the * base width and height of the triangle. */ import java.util.Scanner; class AreaTriangleDemo { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); System.out.println("Enter the width of the Triangle:"); double base = scanner.nextDouble(); System.out.println("Enter the height of the Triangle:"); double height = scanner.nextDouble(); //Area = (width*height)/2 double area = (base* height)/2; System.out.println("Area of Triangle is: " + area); } } ``` 輸出: ```java Enter the width of the Triangle: 2 Enter the height of the Triangle: 2 Area of Triangle is: 2.0 ``` **計劃 2:** ```java /** * @author: BeginnersBook.com * @description: Program to Calculate area of Triangle * with no user interaction. */ class AreaTriangleDemo2 { public static void main(String args[]) { double base = 20.0; double height = 110.5; double area = (base* height)/2; System.out.println("Area of Triangle is: " + area); } } ``` 輸出: ```java Area of Triangle is: 1105.0 ```
                  <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>

                              哎呀哎呀视频在线观看