本帖最後由 tonyh 於 2012-7-28 17:02 編輯
宣告整數變數x與y, 再將值代入做五則運算.- public class ch4
- {
- public static void main(String args[])
- {
- int x=10, y=5;
- System.out.println("當x的值為"+x+", y的值為"+y+"時");
- System.out.println("x+y="+(x+y));
- System.out.println("x-y="+(x-y));
- System.out.println("x*y="+(x*y));
- System.out.println("x/y="+(x/y));
- System.out.println("x%y="+(x%y));
- }
- }
複製代碼 |