標題:
printf() 函式 (二)
[打印本頁]
作者:
tonyh
時間:
2013-4-20 17:10
標題:
printf() 函式 (二)
本帖最後由 tonyh 於 2013-4-20 17:12 編輯
public class ch64
{
public static void main(String args[])
{
String str="Hello! My name is Tony!";
System.out.printf("%s%n",str);
System.out.printf("%S%n",str); // %S 指定大寫格式
double pi=3.14159;
System.out.printf("%.0f%n",pi); // .0 四捨五入至整數位
System.out.printf("%5.2f%n",pi); // 5.2f 中, 5代表總字元數, 2代表四捨五入至小數後第二位
System.out.printf("%8.4f%n",pi);
System.out.printf("%.8f%n",pi);
}
}
複製代碼
作者:
尤泓鈞
時間:
2013-4-20 17:13
public class ch64
{
public static void main(String args[])
{
String str="Hello! My name is Tony!";
System.out.printf("%s%n",str);
System.out.printf("%S%n",str);
double pi=3.14159;
System.out.printf("%.0f%n",pi);
System.out.printf("%5.2f%n",pi);
System.out.printf("%8.4f%n",pi);
System.out.printf("%.8f%n",pi);
}
}
複製代碼
作者:
劉漢文
時間:
2013-4-20 17:15
public class ch64
{
public static void main(String args[])
{
String str="Hello! My name is Tony!";
System.out.printf("%s%n",str);
System.out.printf("%S%n",str);
double pi=3.14159;
System.out.printf("%.0f%n",pi);
System.out.printf("%5.2f%n",pi);
System.out.printf("%8.4f%n",pi);
System.out.printf("%.8f%n",pi);
}
}
複製代碼
作者:
t3742238
時間:
2013-4-20 17:16
public class ch64
{
public static void main(String args[])
{
String str="Hello! My name is Tony!";
System.out.printf("%s%n",str);
System.out.printf("%S%n",str);
double pi=3.14159;
System.out.printf("%.0f%n",pi);
System.out.printf("%5.2f%n",pi);
System.out.printf("%8.4f%n",pi);
System.out.printf("%.8f%n",pi);
}
}
複製代碼
作者:
黃博鴻
時間:
2013-4-20 17:16
public class ch64
{
public static void main(String args[])
{
String str="Hello!My name is Tony!";
System.out.printf("%s%n",str);
System.out.printf("%S%n",str);
double pi=3.14159;
System.out.printf("%.0f%n",pi);
System.out.printf("%5.2f%n",pi);
System.out.printf("%8.4f%n",pi);
System.out.printf("%.8f%n",pi);
}
}
複製代碼
作者:
t2364705
時間:
2013-4-20 17:17
public class ch64
{
public static void main(String args[])
{
String str="Hello!My name is Tony!";
System.out.printf("%s%n",str);
System.out.printf("%S%n",str);
double pi=3.14159;
System.out.printf("%.0f%n",pi);
System.out.printf("%5.2f%n",pi);
System.out.printf("%8.4f%n",pi);
}
}
複製代碼
作者:
蔡昀佑
時間:
2013-4-20 17:25
public class ch64
{
public static void main(String args[])
{
String str="Hello!My name is Tony!";
System.out.printf("%s%n",str);
System.out.printf("%S%n",str);
double pi=3.14159;
System.out.printf("%.0f%n",pi);
System.out.printf("%5.2f%n",pi);
System.out.printf("%8.4f%n",pi);
}
}
複製代碼
作者:
蔡昀佑
時間:
2013-4-20 17:26
public class ch64
{
public static void main(String args[])
{
String str="Hello!My name is Tony!";
System.out.printf("%s%n",str);
System.out.printf("%S%n",str);
double pi=3.14159;
System.out.printf("%.0f%n",pi);
System.out.printf("%5.2f%n",pi);
System.out.printf("%8.4f%n",pi);
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2