標題:
電話簿 (二)
[打印本頁]
作者:
tonyh
時間:
2012-11-15 15:37
標題:
電話簿 (二)
本帖最後由 tonyh 於 2012-11-24 17:04 編輯
[attach]631[/attach]
import java.io.Console;
public class ch42
{
public static void main(String args[])
{
String name;
int sum=0;
String tel[][]={{"大雄","0980-454666"},
{"技安","0911-333898"},
{"宜靜","0922-999579"},
{"阿福","0938-234567"},
{"小叮噹","0911-864356"}};
Console console=System.console();
System.out.println("***小米的電話簿***");
System.out.println("1.輸入'all'顯示完整電話簿\n2.輸入姓名查詢目標對象的電話\n3.輸入'end'結束程式");
System.out.print("請在此輸入: ");
name=console.readLine();
if(name.equals("all")==true)
{
System.out.println("編號\t姓名\t電話");
System.out.println("============================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
for(int j=0; j<=1;j++)
{
System.out.print(tel[i][j]+"\t");
}
System.out.println();
}
}else
{
for(int i=0; i<=4; i++)
{
if(name.equals(tel[i][0])==true)
{
System.out.println(tel[i][0]+"的電話是"+tel[i][1]);
sum++;
}
}
if(sum==0)
{
System.out.println("查無此人!");
}
}
}
}
複製代碼
作者:
黃博鴻
時間:
2012-11-24 16:40
本帖最後由 黃博鴻 於 2012-11-24 17:07 編輯
import java.io.Console;
public class ch42
{
public static void main(String args[])
{
Console console=System.console();
String name;
System.out.println("***明久的電話簿***");
System.out.println("1.請輸入'all'以顯示完整電話簿\n2.輸入名字以顯示目標電話\n3.輸入'end'以結束程式");
System.out.print("請輸入: ");
name=console.readLine();
String tel[][]={{"板本雄二","0985-326124"},{"土屋康太","0987-517640"}
,{"木下秀吉","0956-784356"},{"島田美波","0934-521345"},
{"姬路瑞希","0965-521521"},{"工藤愛子","0956-599599"}};
if(name.equals("all")==true)
{
System.out.println("編號\t姓名\t\t電話號碼");
System.out.println("=====================================");
for(int i=0; i<=5; i++)
{
System.out.print((i+1)+"\t");
for(int j=0; j<=1; j++)
{
System.out.print(tel[i][j]+"\t");
}
System.out.println();
}
} else
{
for(int i=0; i<=5; i++)
{
if(name.equals(tel[i][0])==true)
{
System.out.println("此人的電話號碼"+tel[i][1]);
break;
}else
{
if(name.equals(tel[0][0])==false && name.equals(tel[1][0])==false
&& name.equals(tel[2][0])==false && name.equals(tel[3][0])==false
&& name.equals(tel[4][0])==false && name.equals(tel[5][0])==false)
{
System.out.println("輸入錯誤");
break;
}
continue;
}
}
}
}
}
複製代碼
作者:
尤泓鈞
時間:
2012-11-24 17:05
import java.io.Console;
public class ch42
{
public static void main(String args[])
{
String name;
int sum=0;
String tel[][]={{"大雄","0980-454666"},
{"技安","0911-333898"},
{"宜靜","0922-999579"},
{"阿福","0938-234567"},
{"小叮噹","0911-864356"}};
Console console=System.console();
System.out.println("***##的電話簿***");
System.out.println("1.輸入'all'顯示完整電話簿\n2.輸入姓名查詢目標對象的電話\n3.輸入'end'結束程式");
System.out.print("請在此輸入: ");
name=console.readLine();
if(name.equals("all")==true)
{
System.out.println("編號\t姓名\t電話");
System.out.println("============================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
for(int j=0; j<=1;j++)
{
System.out.print(tel[i][j]+"\t");
}
System.out.println();
}
}else
{
for(int i=0; i<=4; i++)
{
if(name.equals(tel[i][0])==true)
{
System.out.println(tel[i][0]+"的電話是"+tel[i][1]);
sum++
}
}
if(sum==0)
{
System.out.println("查無此人!");
}
}
}
}
複製代碼
作者:
黃博鴻
時間:
2012-11-24 17:07
import java.io.Console;
public class ch42
{
public static void main(String args[])
{
Console console=System.console();
String name;
int sum=0;
System.out.println("***明久的電話簿***");
System.out.println("1.請輸入'all'以顯示完整電話簿\n2.輸入名字以顯示目標電話\n3.輸入'end'以結束程式");
System.out.print("請輸入: ");
name=console.readLine();
String tel[][]={{"板本雄二","0985-326124"},{"土屋康太","0987-517640"}
,{"木下秀吉","0956-784356"},{"島田美波","0934-521345"},
{"姬路瑞希","0965-521521"},{"工藤愛子","0956-599599"}};
if(name.equals("all")==true)
{
System.out.println("編號\t姓名\t\t電話號碼");
System.out.println("=====================================");
for(int i=0; i<=5; i++)
{
System.out.print((i+1)+"\t");
for(int j=0; j<=1; j++)
{
System.out.print(tel[i][j]+"\t");
}
System.out.println();
}
} else
{
for(int i=0; i<=5; i++)
{
if(name.equals(tel[i][0])==true)
{
System.out.println(tel[i][0]+"的電話號碼"+tel[i][1]);
sum++;
}
}
if(sum==0)
{
System.out.println("輸入錯誤");
}
}
}
}
複製代碼
作者:
t2364705
時間:
2012-11-24 17:13
import java.io.Console;
public class ch42
{
public static void main(String args[])
{
String name;
int sum;
String tel[][]={{"大雄","0980-564561"},
{"小夫","0911-333898"},
{"靜香","0922-999579"},
{"胖虎","0938-244567"},
{"小叮噹","0947-864356"}};
Console console=System.console();
System.out.println("***小米的電話簿***");
System.out.println("1.輸入'all'顯示完整電話簿\n2.輸入姓名查詢目標對象的電話\n3.輸入'end'結束程式");
System.out.print("請在此輸入: ");
name=console.readLine();
if(name.equals("all")==true)
{
System.out.println("編號\t姓名\t電話");
System.out.println("============================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
for(int j=0; j<=1;j++)
{
System.out.print(tel[i][j]+"\t");
}
System.out.println();
}
}else
{
for(int i=0; i<=4; i++)
{
if(name.equals(tel[i][0])==true)
{
System.out.println(tel[i][0]+"的電話是"+tel[i][1]);
sum++;
}
}
if(sum==0)
{
System.out.println("查無此人!");
}
}
}
}
複製代碼
作者:
lon
時間:
2012-11-24 17:15
import java.io.*;
public class phone {
public static void main(String[] args) {
int sum=0;
String tel[][]={{"甲","0912-123456"},
{"乙","0923-234567"},
{"丙","0934-345678"},
{"丁","0945-456789"},
{"戊","0956-567891"}};
Console console=System.console();
System.out.println("***小米的電話簿***");
System.out.println("1.輸入all顯示完整電話簿\n2.輸入姓名查詢目標對象的電話\n3.輸入end結束程式");
String name;
name=console.readLine();
if(name.equals("all")==true){
for(int i=0;i<5;i++){
System.out.print((i+1)+"\t");
for(int j=0;j<2;j++){
System.out.println(tel[i][j]);
}
}
}else{
for(int i=0;i<5;i++){
if(name.equals(tel[i][0])==true){
System.out.println(tel[i][0]+"\t"+tel[i][1]);
sum++;
}
}
if(sum==0)
System.out.println("查無此人");
}
}
}
複製代碼
作者:
蔡昀佑
時間:
2012-11-24 17:17
import java.io.Console;
public class ch42
{
public static void main(String args[])
{
String name;
int sum=0;
String tel[][]={{"大雄","0980-454666"},
{"技安","0911-333898"},
{"宜靜","0922-999579"},
{"阿福","0938-234567"},
{"小叮噹","0911-864356"}};
Console console=System.console();
System.out.println("***小米的電話簿***");
System.out.println("1.輸入'all'顯示完整電話簿\n2.輸入姓名查詢目標對象的電話\n3.輸入'end'結束程式");
System.out.print("請在此輸入: ");
name=console.readLine();
if(name.equals("all")==true)
{
System.out.println("編號\t姓名\t電話");
System.out.println("============================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
for(int j=0; j<=1;j++)
{
System.out.print(tel[i][j]+"\t");
}
System.out.println();
}
}else
{
for(int i=0; i<=4; i++)
{
if(name.equals(tel[i][0])==true)
{
System.out.println(tel[i][0]+"的電話是"+tel[i][1]);
sum++;
}
}
if(sum==0)
{
System.out.println("查無此人!");
}
}
}
}
複製代碼
作者:
t3742238
時間:
2012-12-8 14:57
import java.io.Console;
public class ch42
{
public static void main(String args[])
{
String name;
int sum=0;
String tel[][]={{"大雄","0980-454666"},
{"技安","0911-333898"},
{"宜靜","0922-999579"},
{"阿福","0938-234567"},
{"小叮噹","0911-864356"}};
Console console=System.console();
System.out.println("***小米的電話簿***");
System.out.println("1.輸入'all'顯示完整電話簿\n2.輸入姓名查詢目標對象的電話\n3.輸入'end'結束程式");
System.out.print("請在此輸入: ");
name=console.readLine();
if(name.equals("all")==true)
{
System.out.println("編號\t姓名\t電話");
System.out.println("============================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
for(int j=0; j<=1;j++)
{
System.out.print(tel[i][j]+"\t");
}
System.out.println();
}
}else
{
for(int i=0; i<=4; i++)
{
if(name.equals(tel[i][0])==true)
{
System.out.println(tel[i][0]+"的電話是"+tel[i][1]);
sum++;
}
}
if(sum==0)
{
System.out.println("查無此人!");
}
}
}
}
複製代碼
作者:
劉漢文
時間:
2012-12-8 14:58
import java.io.Console;
public class ch42
{
public static void main(String args[])
{
String name;
int sum=0;
String tel[][]={{"大雄","0980-454666"},
{"技安","0911-333898"},
{"宜靜","0922-999579"},
{"阿福","0938-234567"},
{"小叮噹","0911-864356"}};
Console console=System.console();
System.out.println("***小米的電話簿***");
System.out.println("1.輸入'all'顯示完整電話簿\n2.輸入姓名查詢目標對象的電話\n3.輸入'end'結束程式");
System.out.print("請在此輸入: ");
name=console.readLine();
if(name.equals("all")==true)
{
System.out.println("編號\t姓名\t電話");
System.out.println("============================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
for(int j=0; j<=1;j++)
{
System.out.print(tel[i][j]+"\t");
}
System.out.println();
}
}else
{
for(int i=0; i<=4; i++)
{
if(name.equals(tel[i][0])==true)
{
System.out.println(tel[i][0]+"的電話是"+tel[i][1]);
sum++;
}
}
if(sum==0)
{
System.out.println("查無此人!");
}
}
}
}
複製代碼
作者:
粘靖瑜
時間:
2012-12-15 12:12
import java.io.Console;
public class ch42
{
public static void main(String args[])
{
int sum=0;
String name;
String tel[][]={{"大雄","0980-454666"},
{"技安","0911-338888"},
{"宜靜","0922-999579"},
{"阿福","0938-234567"},
{"小叮噹","0911-864356"}};
Console console=System.console();
System.out.println("***小米的電話簿***");
System.out.println("1.輸入'all'顯示完整電話簿\n2.輸入性名查尋目標對象的電話\n3.輸入'end'結束程式");
System.out.print("請在此輸入: ");
name=console.readLine();
if(name.equals("all")==true)
{
System.out.println("編號\t姓名\t電話");
System.out.println("==================================");
for(int i=0; i<=4; i++)
{
System.out.print((i+1)+"\t");
for(int j=0; j<=1;j++)
{
System.out.print(tel[i][j]+"\t");
}
System.out.println();
}
}else
{
for(int i=0; i<=4; i++)
{
if(name.equals(tel[i][0])==true)
{
System.out.println(tel[i][0]+"的電話是"+tel[i][1]);
sum++;
}
}
if(sum==0)
{
System.out.println("查無此人!");
}
}
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2