promotion image of download ymail app
Promoted
? asked in 電腦與網際網路程式設計 · 1 decade ago

java程式 誰可以寫給我看?徵程式高手 thx

write a java program with a main method that asks the user three

double numbers and displays the sum,average,product of those three

numbers on the screen

1 Answer

Rating
  • 1 decade ago
    Favorite Answer

    請把這個貼上去後在dos視窗執行或是編輯軟體執行。

    import java.io.*;

    class MATH

    {

    public static void main(String args[]) throws IOException

    {

    System.out.println("請輸入油量:");

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String a = br.readLine();

    String b = br.readLine();

    String c = br.readLine();

    double aa = Double.parseDouble(a);

    double bb = Double.parseDouble(b);

    double cc = Double.parseDouble(c);

    double sum;

    double average;

    int total = 100;

    double product;

    sum = aa+bb+cc;

    average = sum/total;

    product = aa*bb*cc;

    System.out.println("sum = "+sum);

    System.out.println("average = "+average*100+"%");

    System.out.println("prodct = "+product);

    }

    }

    2008-04-16 21:03:56 補充:

    有任何問題請至我的部落格~~^^

    http://tw.myblog.yahoo.com/slamgundam

    2008-04-17 01:33:49 補充:

    System.out.println("請輸入油量:");

    這個部分改成"請輸出三個數字"

    不好意思喔~~^^

    2008-04-17 10:39:46 補充:

    int total = 100; 改成 int total = 300; 為什麼呢? 因為要輸入三個數值取平均值

    不好意思喔~寫程式的時候有點腦殘@@~

    Source(s): 自己[陷入java與AS3.0的混沌], 自己[陷入java與AS3.0的混沌], 自己, 自己
    • Commenter avatarLogin to reply the answers
Still have questions? Get your answers by asking now.