Java Programming, Loose-leaf Version
Java Programming, Loose-leaf Version
8th Edition
ISBN: 9781337685917
Author: Joyce Farrell
Publisher: Cengage Learning
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
D. S. Malik, Data Structures Using C++, 2nd Edition, 2010
Methods (Ch6) - Review 1. (The MyRoot method) Below is a manual implementation of the Math.sqrt() method in Java. There are two methods, method #1 which calculates the square root for positive integers, and method #2, which calculates the square root of positive doubles (also works for integers). public class SquareRoot { public static void main(String[] args) { } // implement a loop of your choice here // Method that calculates the square root of integer variables public static double myRoot(int number) { double root; root=number/2; double root old; do { root old root; root (root_old+number/root_old)/2; } while (Math.abs(root_old-root)>1.8E-6); return root; } // Method that calculates the square root of double variables public static double myRoot(double number) { double root; root number/2; double root_old; do { root old root; root (root_old+number/root_old)/2; while (Math.abs (root_old-root)>1.0E-6); return root; } } Program-it-Yourself: In the main method, create a program that…
I would like to know the main features about the following 3 key concepts:1. Backup Domain Controller (BDC)2. Access Control List (ACL)3. Dynamic Memory
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
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning