Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that reads a file of phone numbers and names. The user should then be able to enter a name from the keyboard

Write a program that reads a file of phone numbers and names. The user should then be able to enter a name from the keyboard and the program will display the phone number of that person. The program should continue to ask for names until the user enters end.

Needed done ASAP please.

image text in transcribed

phonebook.txt:

(104)496-9416 Adele (646)124-2129 Al Schmitt (798)604-8480 Alicia Keys (602)326-7747 Alison Krauss (609)304-1979 Aretha Franklin (722)100-9889 Arif Mardin (824)845-5464 Beyonc (904)718-8852 Bonnie Raitt (481)250-1133 Bruce Springsteen (895)181-7320 CeCe Winans (893)913-7493 Chaka Khan (707)311-8293 Chick Corea (344)156-9641 David Foster (721)329-7267 David Frost (186)220-9902 Ella Fitzgerald (647)587-5317 Emmylou Harris (330)616-5507 Georg Solti (479)507-7463 Henry Mancini (608)264-1059 Hillary Scott (427)273-7027 James Mallinson (110)889-7502 Jay David Saks (213)274-1190 Jay-Z (342)824-3813 Jimmy Sturr (821)795-3847 John Williams (625)431-3861 Kanye West (559)466-7754 Leontyne Price (302)478-2751 Linda Ronstadt (257)898-1735 Mary J. Blige (939)486-6784 Natalie Cole (191)319-4859 Norah Jones (677)219-8288 Pat Metheny (198)302-2776 Paul McCartney (571)805-3814 Phil Ramone (564)111-4698 Pierre Boulez (837)610-5856 Quincy Jones (833)340-3316 Robert Woods (656)101-5431 Sheryl Crow (251)723-4446 Shirley Caesar (486)222-5718 Steven Epstein (856)747-5588 Stevie Wonder (664)770-9049 T Bone Burnett (334)797-5265 Taylor Swift (122)392-8434 Tony Bennett (917)574-9166 Vince Gill (281)201-1265 Vladimir Horowitz (336)423-2033 Yo-Yo Ma 
Write a program that reads a file of phone numbers and names. The user should then be able to enter a name from the keyboard and the program will display the phone number of that person The program should continue to ask for names until the user enters "end". The file phonebook.txt has no more than 100 lines where each line contains phone number individual's phone number in the format (123)456-7890 the name of the person with this phone number. The name might have multiple parts, such as first and last name, separated by spaces. Some names do not. name Your program will want to read the file and create PhoneNumber objects with the name and phone number. The PhoneNumber objects should be kept in an array. The PhoneNumber class should have two class instance variables to hold the phone number and name. It will need a constructor to initialize these two variables to constructor parameters. Program outline number:Count 0 while more data in the file read the phone number from the file read the name using nextline0 and trim the name create a PhoneNumber object with the number and name put the object in the array increment numberCount read a desired name from the keyboard while the desired name is not "end" found is false for each element i in the array up to numberCount if the desired name- array[i].name display desired name and array[i] phone found is true if not found display not found read a desired name from the keyboard Sample output Enter a name >Jay-2 Jay-z has the phone number (213) 274-1190 Enter a name >Bruce Springsteen Bruce Springsteen has the phone number (481) 250-1133 Enter a name >Donald Trump Donald T Enter a name >end rump was not found

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions

Question

2. Identify and choose outcomes to evaluate a training program.

Answered: 1 week ago