返回列表 發帖

變數宣告

  1. public class ch03
  2. {
  3.    public static void main(String args[])
  4.    {
  5.        int x=15, y=10;
  6.        System.out.println("當x的值為"+x+", y的值為"+y+"時...");
  7.        System.out.println("x+y="+(x+y));
  8.        System.out.println("x-y="+(x-y));
  9.        System.out.println("x*y="+(x*y));
  10.        System.out.println("x/y="+(x/y));
  11.        System.out.println("x%y="+(x%y));
  12.    }
  13. }
複製代碼

回復 1# tonyh


   
public class ch03
{
  public static void main(String args[])
  {
    int x=15,y=3;
   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));
   System.out.println("x^y="+(x^y));

  }
}

TOP

  1. public class ch03 //類別
  2. {
  3. public static void main(String args[]) //方法
  4. {
  5.    int x=18, y=14;
  6.    System.out.println("當x值等於"+x+",y值等於"+y+"時...");
  7.    System.out.println("x+y="+(x+y));
  8.    System.out.println("x-y="+(x-y));
  9.    System.out.println("x*y="+(x*y));
  10.    System.out.println("x/y="+(x/y));
  11.    System.out.println("x%y="+(x%y));
  12. }

  13. }
複製代碼

TOP

  1. public class ch03  //類別
  2. {
  3.   public static void main (String arg[]) //方法
  4.   {
  5.     int x=9,y=4 ;
  6.     System.out.println ("偷偷跟你說當x的值為"+x+"而y值為"+y+"的時候...");
  7.     System.out.println ("x+y="+(x+y));
  8.     System.out.println ("x-y="+(x-y));
  9.     System.out.println ("x*y="+(x*y));
  10.     System.out.println ("x/y="+(x/y));
  11.     System.out.println ("x%y="+(x%y));
  12.   }
  13. }
複製代碼

TOP

  1. public class ch03
  2. {
  3.    public static void main (String showdemo[])
  4.    {
  5.     int x=7,y=1;
  6.     System.out.println("when x="+x+", y="+y);
  7.     System.out.println("x+y="+(x+y));
  8.     System.out.println("x-y="+(x-y));
  9.     System.out.println("x*y="+(x*y));
  10.     System.out.println("x/y="+(x/y));
  11.     System.out.println("x%y="+(x%y));
  12.    }
  13. }
複製代碼

TOP

返回列表