package 김현준;
import java.util.Scanner;
class Phone {
public String name;
public int tel;
public Phone(String name, int tel) {
this.name = name;
this.tel = tel;
}
}
public class Main1 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("인원수>>");
int p = input.nextInt();
Phone ph[]= new Phone[p];
for(int i=0;i<p;i++) {
System.out.print("이름과 전화번호(번호는 연속적으로 입력)>> ");
String n= input.next();
int t = input.nextInt();
ph[i]=new Phone(n,t);
}
System.out.println("저장되었습니다...");
while(true) {
System.out.print("검색할 이름>>");
String s = input.next();
if(s.equals("exit"))
{
System.out.println("프로그램을 종료합니다.....");
return ;
}
int flag=0;
for(int j=0;j<p;j++) {
if(ph[j].name.equals(s)) flag=j+1;
}
if(flag>0) System.out.println(s+"의 번호는 "+ ph[flag-1].tel + " 입니다.");
else System.out.println(s+ " 이 없습니다.");
}
// TODO Auto-generated method stub
}
}