標題:
printf() 輸出練習
[打印本頁]
作者:
tonyh
時間:
2019-8-7 14:09
標題:
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-8-7 14:32
public class Ch02 {
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-8-7 14:32
import java.util.Scanner;
import java.util.Arrays;
public class Ch60 {
public static void main(String args[]){
String str1="dog",str2="cat";
int a=4,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-8-7 14:32
import java.util.Scanner;
public class ch02 {
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-8-7 14:33
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-8-7 14:33
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 %Ss totally weigh %.2f pounds",a,str1,b,str2,total);
}
}
複製代碼
作者:
許育慈
時間:
2019-8-7 14:34
import java.util.Scanner;
public class Ch01 {
public static void main(String[] args) {
int d=3,c=5;
String str1="dog",str2="cat";
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds.",d,str1,c,str2,total);
}
}
複製代碼
作者:
張書涵
時間:
2019-8-7 14:34
public class Ch01 {
public static void main(String[] args) {
String str1="dog", str2="cat";
int a=3, b=5;
double weigh=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %5.2f pounds.", a, str1, b, str2, weigh);
}
}
複製代碼
作者:
潘憶承
時間:
2019-8-7 14:34
public class Ch30{
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-8-7 14:34
import java.util.Scanner;
public class Ch11 {
static int f(int b)
{
if(b==1)
{
return 1;
}else
{
return b*f(b-1);
}
}
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int a=3,b=5;
double t=21.985;
String str1="dog",str2="cat";
System.out.printf("There are %d%ss and %d %Ss totally weight%.2f pounds",a,str1,b,str2,t);
}
}
複製代碼
作者:
余映均
時間:
2019-8-7 14:34
public class Ch02 {
public static void main(String[] args) {
int a=3,b=5;
String Str1="dog",Str2="cat";
double total=21.3568;
System.out.printf("There are %d %ss and %d %Ss totally weigh %.2f pounds.",a,Str1,b,Str2,total);
}
}
複製代碼
作者:
黃芊嬡
時間:
2019-8-7 14:34
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-8-7 14:35
_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-8-7 14:35
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-8-7 14:35
public class Ch10
{
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-8-7 14:37
public class Ch51
{
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-8-7 14:38
public class Ch01{
public static void main(String[] args)
{
String str1="dog",str2="cats";
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://seed.istak.org.tw/)
Powered by Discuz! 7.2