xam3000f 10 發表於 December 13, 2008 檢舉 Share 發表於 December 13, 2008 請問怎麼寫一個在cmd.exe模式下執行java計算的計算機程式這是我寫到不會寫的程式碼import java.lang.*; class test { public static void main(String[] args) { long a = 0, b = 0 ; double end =0; char c = ' '; a = Integer.parseInt(args[0]); c = args[1]; b = Integer.parseInt(args[2]); switch© { case '+': end=a+b; break; case '-': end=a-b; break; case '*': end=a*b; break; case '/': end=a/b; break; case '^': end=Math.pow(a,b); break; default: System.out.println("運算符號錯誤"); } System.out.println(a+" "+c+" "+b+" = "+end); } }因為老師教的ooxx所以我不太懂宣告= ="就是輸入java test 數字 運算符號 數字= =" 鏈接文章 分享到其他網站
yel155653 10 發表於 February 26, 2009 檢舉 Share 發表於 February 26, 2009 import java.lang.*; class test {public static void main(String[] args) { long a , b;double end=0 ;String c ; a = Integer.parseInt(args[0]); c = (args[1]); b = Integer.parseInt(args[2]); if(c.equals("+")) end=a+b; else if(c.equals("-")) end=a-b; else if(c.equals("*")) end=a*b; else if(c.equals("/")) end=a/b; else if(c.equals("^")) end=Math.pow(a,b);else System.out.println("運算符號錯誤");System.out.println(a+" "+c+" "+b+" = "+end); } } 如上xd 鏈接文章 分享到其他網站
Recommended Posts
請登入後來留意見
在登入之後,您才能留意見
立即登入