標題:
printf() 輸出練習 (一)
[打印本頁]
作者:
tonyh
時間:
2020-2-5 13:57
標題:
printf() 輸出練習 (一)
試以 printf() 方法做字串輸出。
%d 整數
%s 字串
%S 轉換為大寫字母的字串
%.2f 四捨五入至小數點後2位
public class Ch60
{
public static void main(String[] args)
{
String str1="dog", str2="cat";
int a=3, b=5;
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
邱翊博
時間:
2020-2-5 14:17
package blueming;
public class blueming {
public static void main(String[] args) {
String str1="dog", str2="cat";
int a=3, b=5;
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
蔡承翰
時間:
2020-2-5 14:17
public class Ch01{
public static void main(String args[]){
String str1="dog",str2="cat";
int a=3,b=5;
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weith %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
劉家銘
時間:
2020-2-5 14:17
public class Ch60 {
public static void main(String[] args) {
String str1="dog", str2="cat";
int a=3, b=5;
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
盧弘毅
時間:
2020-2-5 14:17
import java.util.Scanner;
public class Ch99 {
public static void main(String[] args) {
String str1="dog",str2="cat";
int a=3,b=5;
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
張宸翔
時間:
2020-2-5 14:17
public class Ch01 {
public static void main(String[] args) {
String str1="dog",str2="cat";
int a=3, b=5;
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds",a,str1,b,str2,total);
}
}
複製代碼
作者:
楊秉樺
時間:
2020-2-5 14:18
public class Ch47
{
public static void main(String[] args) {
String str1="dog",str2="cat";
int a=3,b=5;
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
黃煜城
時間:
2020-2-5 14:18
public class Ch25 {
public static void main(String[] args)
{
String str1="dog", str2="cat";
int a=3, b=5;
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
何蕙妘
時間:
2020-2-5 14:18
public class Ch55 {
public static void main(String[] args)
{
int a=3,b=5;
String str1="dog",str2="cat";
double total=21.3568;
Scanner s=new Scanner(System.in);
System.out.printf("There are %d %ss and %d %Ss totally weigh %2f pound",a,str1,b,str2,total);
}
}
複製代碼
作者:
蘇宜貞
時間:
2020-2-5 14:18
public class Ch01
{
public static void main(String[] args)
{
String str1="dog", str2="cat";
int a=3, b=5;
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds",a,str1,b,str2,total);
}
}
複製代碼
作者:
蘇行一
時間:
2020-2-5 14:19
public class Ch1
{
public static void main(String[] args)
{
String str1="dog",str2="cat";
int a=3,b=5;
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
陳梓瑜
時間:
2020-2-5 14:20
public class Ch46 {
public static void main(String[] args)
{
String str1="dog",str2="cat";
int a=3,b=5;
double total=21.3568;
System.out.printf("There are %d %ss and %d %ss totally weigh %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
沙芃妘
時間:
2020-2-5 14:25
package ggg;
import java.util.Scanner;
public class Ch40{
public static void main(String[] args)
{
String str1="dog",str2="cat";
int a=3,b=5;
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2