- import java.io.Console;
- public class ch41
- {
- 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();
- }
- }
- }
- }
複製代碼 |