打印表格

【5】顯示下面表格,將浮點數值類型轉換爲整數。

package test;

public class test2 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		/*
		 * 打印表格
		 * 將浮點數值類型轉換爲整數
		 */
		System.out.print("a"+"     "+"b"+"     "+"pow(a,b)");
		System.out.println();
		for(int a=1,b=2;a<=5&&b<=6;a++,b++)
		{
			System.out.print(a+"     "+b+"     ");
			System.out.print((int)(Math.pow(a, b)));
			System.out.println();
		}

	}

}

在這裏插入圖片描述