Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help Write a phonebook application. it shouid use arrays to storn irformafon about mary ghorebook entries. Each ontry should consiet of a frst name

please help
image text in transcribed
Write a phonebook application. it shouid use arrays to storn irformafon about mary ghorebook entries. Each ontry should consiet of a frst name (a Stringl. a iast rame (a String) and a phone rumber (a String, assumed to be of the form nne-min-nnnn, such as 212-563-69e7). In addition to storng this information, the program should allow users to performin same aperations with Ehe cata, such as lookup and reverse iookup. The data shouid be slored in three arrays of Strngs: one for the first names one for the last names, and one far the phone numbers. Give each array a size of Max_ENTHIEB, a constant which theuld be initialized to 10 Near the beginning of the program, the program should read is the inifial database of phonebook entries from a file (whose name should be provided by the user) and store the data in the arrays. The exact numbet of lines in the fie is not known in advance. However, yos can assume that the file eentains no moe than 10 lines. and that each line hes the following farmat. Hirsterase last_naze phene_nueber For exarmple: one ine of the the might be. Jahn Sas 234-657-1234 You can assume that there are no tio lines in the file with the same combination of fint name atd last name. For exarnple, you can assume that there will not be two lines with the name Johy Doe (However, it is possible for the tile to contain the name Jane Doe in addition to Jotn Doe) After reading in the data and storing it in the arreys. the progam shoid prowide the user with a list of eptiont as described below Based on tha user's response, the program should obtain aty a dabonat needed information from the user, and pectorm the requested task. The program should repeatedy do this antil the user indicatas that they would tike to qut the program. The optens art - I (lookioj The program shoudd ask for a first name and a last name. it there is an entry that has that combinaton of trst name and last name, the program shouid print the informaton about that entry. (Assume that these are no two enbies that share the same combination of first name and last name) othersise, the program ahould print an error mesage. - r (ruverse lookup). Toe program should ask tor a phone number, and should print the first name and last name of the entry that has that phane number. (if there are mulliple entries with the same phone number, then print any of thowe entice.) Ir there is no enty that has that phone number, the progam should print an wror mesage. - o (change puncer): This opton aliows the user to updais an entry's phone number. The program should ask for a first name and a last name, If there is an ertry with that combination of frst name and last name. the program should ask for the new phone number and update the phone humber for the appropnate entiy: Oeherwhe. Ithe program should print an entor meseage. - a (add entry) This opoon alows the user ts update an entry's phone number if there is ns room in the arrays for another entry (that is, if the curent number of entries is equal to MAX EN Thie5), the program should pent an ecror message. Otherwise, the program should ask fsr a first name and a last name it there aireedy is an entry wth this combiration of frat name end last narne, the program should peint an enar message. Cotherwise, the program should ask for a phone momber and add the new entry to the arrays. - q (quit): This option alows the vser to quit the peogram. Ir the vaser enters any oither choloe. the program should pvint an entor message. At the end of the program. once the user has desided to quit, the program should prat the updased database so a file (ahose namie should be provides by the usen in the same format as the input the. link. (Note that this particular input fie contains exactly 8 lines. but the program should be designed to work wath an input file that has anywhere between 0 and 10 tres.) Ar the end. this sample run priets a tie named entries_output txt. which you can see at this tint Note: Do not ceate multiple seanners for reading keyboard irput. inateod, treate ene keyboard scanner in the main method, and then pass it is the oher metheds as needed. Codelab has issues when you create maltple Scanners for reading keyboard inpue Additonally, even withoul Codelab, ifs good ta minimize the number of cbjects that a pragran creates Another note: Do not use Scanner's nextiline method to read in a String (tuch as a file name) instead use Scannera nevt method. Astibosw Biale: + anitick_nsut bxt ahculd aof be modined

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

Graph Database Modeling With Neo4j

Authors: Ajit Singh

2nd Edition

B0BDWT2XLR, 979-8351798783

More Books

Students also viewed these Databases questions