2009年3月2日 星期一

Lab Java casting

Write a Java program as follows:

Let m=1, n=2;
Print m/n
Print m/ (double)n;
Print (double) m/n;

------------------------------------------------<程式碼開始>--------------------------------------

public class hanyi
{
public static void main( String[] args )
{
int m = 1, n = 2;
System.out.println( "Write a Java program as follows:\nm = 1, n = 2");
System.out.println( "Print m/n = "+ m/n );
System.out.println( "Print m/ (double)n = " +  m/ (double)n);
System.out.println( "Print (double) m/n = " + (double) m/n );
}
}
------------------------------------------------<程式碼結束>--------------------------------------

沒有留言:

張貼留言