標題:
printf() 輸出練習
[打印本頁]
作者:
tonyh
時間:
2019-7-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);
}
}
複製代碼
作者:
宋威廷
時間:
2019-7-5 14:33
public class CH07
{
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);
}
}
複製代碼
作者:
古蕾娜
時間:
2019-7-5 14:34
import java.util.Scanner;
public class Ch06
{
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);
}
}
複製代碼
作者:
李承洋
時間:
2019-7-5 14:35
public class Ch18 {
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);
}
}
複製代碼
作者:
賴駿榮
時間:
2019-7-5 14:36
public class CH07
{
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);
}
}
複製代碼
作者:
陳柏銓
時間:
2019-7-5 14:36
public class Ch134 {
public static void main(String[] args) {
String str1="dog", str2="cat";
int a=3, b=5;
double total=21.3568713405;
System.out.printf("There are %d %ss and %d %Ss totally weight %.3f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
蔡杰恩
時間:
2019-7-5 14:36
public class Ch87 {
public static void main(String[] args) {
String str1="dog",str2="cat";
int a=3,b=5;
double num=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds.",a,str1,b,str2,num);
}
}
複製代碼
作者:
古昇暘
時間:
2019-7-5 14:36
package o;
import java.util.Scanner;
public class foraddfinal
{
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 %s and %d %s totally weigh %.2f" ,a,str1,b,str2,total);
}
}
複製代碼
作者:
陳智鈞
時間:
2019-7-5 14:36
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);
}
}
複製代碼
作者:
陳璽安
時間:
2019-7-5 14:37
public class Ch15 {
public static void main (String[] args)
{
String strl="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);")
}
}
複製代碼
作者:
李佳諭
時間:
2019-7-5 14:37
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);
}
}
複製代碼
作者:
林宥杰
時間:
2019-7-5 14:37
public class Ch01
{
public static void main(String[] args)
{
String st1="dog",str2="cat";
int a=3,b=5;
double total=21.3568;
System.out.printf("There are %d %s and %d %S totally weigh %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
李從赫
時間:
2019-7-5 14:37
public class Ch03 {
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);
}
}
複製代碼
作者:
張啟廣
時間:
2019-7-5 14:37
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 %s and %d %S totally weigh %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
王煦
時間:
2019-7-5 14:38
import java.util.Scanner;
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 weight %.2f pounds.",a,str1,b,str2,total);
}
}
複製代碼
作者:
吳庭慈
時間:
2019-7-5 14:38
public class Ch03
{
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);
}
}
複製代碼
作者:
劉欽文
時間:
2019-7-5 14:39
import java.util.Scanner;
public class Ch12 {
public static void main(String[] args)
{
String str1="dog",st2="cat";
int a=3,b=5;
double total=21.2568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2fpounds.",a,str,b,sttr2,total);
}
}
複製代碼
作者:
葉子于
時間:
2019-7-5 14:39
public class ch06 {
public static void main(String[] args) {
String s1="dog",s2="cat";
int a=3,b=5;
double t=3.5555646614;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds.",a,s1,b,s2,t);
}
}
複製代碼
作者:
謝宗佑
時間:
2019-7-5 14:39
public class Ch20
{
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);
}
}
複製代碼
作者:
蔡杰希
時間:
2019-7-5 14:51
import java.util.Scanner;
public class Ch01
{
public static void main(String[]args)
{
Scanner s=new Scanner(System.in);
String str1="dog",str2="cat";
int a=3,b=5;
double total=21.3568;
System.out.printf("There're %d %ss and %d %Ss totally weigh %.2f pounds.",a,str1,b,str2,total);;
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2