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        I asked my teacher for help and he sent me this but it just confused me more - 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 listings = new ArrayList(); 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

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter8: Working With Advanced Functions
Section: Chapter Questions
Problem 4.4CP
icon
Related questions
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

 
    
I asked my teacher for help and he sent me this but it just confused me more -
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Linux
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage