EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
Expert Solution & Answer
Book Icon
Chapter 8, Problem 9PE

Explanation of Solution

Program:

File name: “PhoneNumbers.java

//Import necessary header files

import javax.swing.*;

//Define a class named PhoneNumbers

class PhoneNumbers

{

    //Define a main method

    public static void main(String[] args)

    {

        /*Declare an array to store first names for 30 people*/

        String[] names = new String[30];

        //Assign names for 10 people

        names[0] = "Gina";    names[1] = "Marcia";

        names[2] = "Rita";    names[3] = "Jennifer";

        names[4] = "Fred";    names[5] = "Neil";

        names[6] = "Judy";    names[7] = "Arlene";

        names[8] = "LaWanda"; names[9] = "Deepak";

        /*Declare an array to store numbers for 30 people*/

        String numbers[] = new String[30];

        //Assign numbers for 10 people

        numbers[0] = "(847) 341-0912";

        numbers[1] = "(847) 341-2392";

        numbers[2] = "(847) 354-0654";

        numbers[3] = "(414) 234-0912";

        numbers[4] = "(414) 435-6567";

        numbers[5] = "(608) 123-0904";

        numbers[6] = "(608) 435-0434";

        numbers[7] = "(608) 123-0312";

        numbers[8] = "(920) 787-9813";

        numbers[9] = "(930) 412-0991";

        //Declare the variables and initialize the value

        String entryName, entryPhone;

        int x;

        boolean isFound = false;

        int highest = 10;

        //Prompt the user to enter a name

        entryName = JOptionPane.showInputDialog(null,

           "Enter name to look up. Type 'quit' to quit.");

        /*While the user enters a name until the arrays are full

        and until the user enters quit*/   

        while (highest < 30 && !entryName.equals("quit"))

        {

            //For loop to be executed until x exceeds highest

            for(x = 0; x < highest; ++ x)

                /*If the name is found in the list, display the

                corresponding phone number*/

                if(entryName...

Blurred answer
Students have asked these similar questions
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
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. Using Scanner.input to prompt user, Use the following names and phone numbers: 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
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:
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning