Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
This is the question I am stuck on -
A personal phone directory contains room for first names and phone numbers for 30 people. Assign names and phone numbers for the first 10 people. Prompt the user for a name, and if the name is found in the list, display the corresponding phone number. If the name is not found in the list, prompt the user for a phone number, and add the new name and phone number to the list.
Continue to prompt the user for names until the user enters quit. After the arrays are full (containing 30 names), do not allow the user to add new entries.
Use the following names and phone numbers:
Name | Phone # |
---|---|
Gina | (847) 341-0912 |
Marcia | (847) 341-2392 |
Rita | (847) 354-0654 |
Jennifer | (414) 234-0912 |
Fred | (414) 435-6567 |
Neil | (608) 123-0904 |
Judy | (608) 435-0434 |
Arlene | (608) 123-0312 |
LaWanda | (920) 787-9813 |
Deepak |
(930) 412-0991 |
When the user types in a name that is not in the phone book, the program should ask for the number and add it to the parallel arrays (space permitting). It looks like you have a second set of arrays where you add new numbers. The arrays should be declared size 30 and the first 10 positions filled. Something like this:
final int MAX_PHONEBOOK_SIZE = 30;
String[] myLittleBlackBookNames = new String[MAX_PHONEBOOK_SIZE];
String[] myLittleBlackBookNumbers = new String[MAX_PHONEBOOK_SIZE];
int nextPosition = 10;
boolean isFound = false;
myLittleBlackBookNames[0] = "Gina";
myLittleBlackBookNumbers[0] = "(847) 341-0912";
myLittleBlackBookNames[1] = "Marcia";
myLittleBlackBookNumbers[1] = "(847) 341-2392";
myLittleBlackBookNames[2] = "Rita";
myLittleBlackBookNumbers[2] = "(847) 354-0654";
myLittleBlackBookNames[3] = "Jennifer";
myLittleBlackBookNumbers[3] = "(847) 341-0912";
myLittleBlackBookNames[4] = "Fred";
myLittleBlackBookNumbers[4] = "(847) 341-0912";
myLittleBlackBookNames[5] = "Neil";
myLittleBlackBookNumbers[5] = "(608) 123-0904";
myLittleBlackBookNames[6] = "Judy";
myLittleBlackBookNumbers[6] = "(608) 435-0434";
myLittleBlackBookNames[7] = "Arlene";
myLittleBlackBookNumbers[7] = "(608) 123-0312";
myLittleBlackBookNames[8] = "LaWanda";
myLittleBlackBookNumbers[8] = "(920) 787-9813";
myLittleBlackBookNames[9] = "Deepak";
myLittleBlackBookNumbers[9] = "(930) 412-0991";
This is the code I tried to do but honetsly I made it worse and even lost the checks I had right -
import java.util.*;
class PhoneNumbers {
public static void main(String[] args) {
// Write your code here
String number;
String name;
String Phonebook;
ArrayList<Phonebook> listings = new ArrayList<Phonebook>();
Scanner sc = new Scanner(System.in);
Phonebook p1 = new Phonebook("John", "2235647892");
listings.add(p1);
Phonebook p2 = new Phonebook("Steve", "8917643292");
listings.add(p2);
Phonebook p3 = new Phonebook("George", "8012374199");
listings.add(p3);
Phonebook p4 = new Phonebook("James", "8435639954");
listings.add(p4);
Phonebook p5 = new Phonebook("Alan", "9913005600");
listings.add(p5);
Phonebook p6 = new Phonebook("Phillip", "2215559327");
listings.add(p6);
Phonebook p7 = new Phonebook("Jared", "9096879923");
listings.add(p7);
Phonebook p8 = new Phonebook("Greg", "6761234567");
listings.add(p8);
Phonebook p9 = new Phonebook("Stewart", "3386253434");
listings.add(p9);
Phonebook p10 = new Phonebook("Scott", "9113456221");
listings.add(p10);
String search = "";
while(listings.size()<30){
System.out.print("Enter search name: ");
search = sc.next();
if(search.equalsIgnoreCase("quit")) break;
boolean foundValue = false;
for(int i =0; i<listings.size(); i++){
if(listings.get(i).getName().equalsIgnoreCase(search)){
System.out.println("Found: "+ listings.get(i).getName()+" "+listings.get(i).getNumber());
foundValue = true;
}
}
if(foundValue == false){
System.out.println("The name "+ search +" was not found");
System.out.print("Enter the phone number for "+ search+": ");
String s = sc.next();
Phonebook newListing = new Phonebook(search, s);
listings.add(newListing);
}
}
}
}
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Question 12 What is the label to reach the commands to invoke the Operating System O/S? Question 13 What register contains the value for conditional statement for execution of the loop?arrow_forwardUsing Java, create a personal directory that contains a data structure for first name, last name, email address and phone number. The data structure should be able to contain the information for an unlimited number of people (depending on system resources).• The program interface should consist of a menu that provides the user with ways to (at least):▪ Add: Get data from user and add the data to the structure.▪ View: which will view the current data in the directory ▪ Edit/Update: Edit existing data ▪ Remove: Delete an entry▪ Search: which prompts the user for search criteria (program should be smart enough to know how to tell what kind of data is being searched for. Try to make this as versatile as possible). Display the data if found. If not found add the new information to the data structure (you must provide the right input for this).The program should store the data in a file so that the program can be run whenever the user wants, even after closing.• Your program should:▪ Contain…arrow_forwardWhich data type stores only whole numbers?arrow_forward
- How are the continue and break lines different?arrow_forwardReplace all the 0 (Zero) digits in your ID by 4. Example: If your ID is 382200448 , it becomes 382244448 Take the first 6 digits and substitute them in this expression (( A + B) / C) * ((D-E)/F)-2) according to the following table; [1 mark] Letter Replace by Digit Example Digit A 1st 3 B 2nd 8 C 3rd 2 D 4th 2 E 5th 4 F 6th 4 After substitution your expression ? Draw a rooted tree that represents your expression. [3 marks] What is the prefix form of this expression. [3 marks] What is the value of the prefix expression obtained in step 2 above? [3 marks]arrow_forwardWrite the parameterList for a procedure that receives a Decimal value followed by the address of a Decimal variable. Use decSales and decBonus as the parameter names.arrow_forward
- this is the information that has to be hard-coded: # hard-coded calls jim = User(first_name='Jim', last_name='Bob', user_id=1000, last_login='June 12, 1998', password='password123') jim.describe_user() jim.greet_user() joe = User('Joe', 'Bob', 1001, 'July 4, 2001', 'babygirl') joe.greet_user() joe.describe_user()arrow_forwardCould you help me with this one too, please Regex, APIs, BeautifulSoup: python import requests, refrom pprint import pprintfrom bs4 import BeautifulSoup complete the missing bodies of the functions below: def group_chat(text_message, friend):"""Question 2- Your friends are blowing up your group chat. Given a string of text messagesfrom your friends and a specific friend's name, return the first text messagethey sent, excluding their name.- Each text message ends with either a ?, !, or .- Your code must be written in one line. Args:text_message (astr)friend (astr)Returns:str of first match>>> text_message = "Madison: How are you guys going today?" + \"Anna: I'm doing pretty well!" + \"Madison: That's good to hear. How is everyone else?">>> friend = "Madison">>>group_chat(text_message, friend)How are you guys going today?"""pass test code: # text_message = "Madison: How are you guys going today?" + \# "Anna: I'm doing pretty well!" + \#…arrow_forwardWrite a stored procedure named displayCountryMessage(). The displayCountryMessage () should receive one input argument for the country name and then based on that input argument, display a short message and the name of the country. Otherwise, if the country does not exist in the country table, then the procedure should display an appropriate message. For example, if I call the displayCountryMessage() procedure and pass it “France”, then it will display the message “France exists in the Country table”. If I call the displayCountryMessage()procedure and pas it “AAAAA”, then it will display the message “AAAAA does NOT exist in the Country table”.arrow_forward
- yout References Mailings Review View Help Grammarly 7. Convert the following numbers from a specific base to another base. a. 1236 to base 5 (i.e. Convert from base 6 to base 5) b. 7648 to base 4 __(i.e. Convert from base 8 to base 4) c. 2345 to base 4 (i.e. Convert from base 6 to base 4)arrow_forwardNEED HELP WITH PYTHON CODE. ALSO, PLEASE PROVIDE DETAILS SEPARATELY ON HOW AND WHAT DID U USE TO GET UR CODE DONE.arrow_forwardFor this week's assignment you will allow the user to add employee, view all employees, search employee by ssn, and edit employee information. Below this is what its supposed to look like when completed. I have also included what I started to do but I can't figure out how to add the search by SSN option or the edit employee option. If you can give me a step by step on how to do this in python I would greatly appreciate it.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education