MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
9th Edition
ISBN: 9780357505526
Author: FARRELL
Publisher: CENGAGE L
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
In the composer array, create a statement that copies the string "Beethoven."
Assignment 5A: Multiple Frequencies. In the last assignment, we calculated the frequency of a coin flip. This required us to have two separate variables, which we used to record the number of heads and tails. Now that we know about arrays, we can track the frequency of all numbers in a randomly generated sequence. For this program, you will ask the user to provide a range of values (from 1 to that number, inclusive) and how long of a number sequence you want to generate using that number range. You will then generate and save the sequence in an array. After that, you will count the number of times each number occurs in the sequence, and print the frequency of each number. Hints: You can use multiple arrays for this assignment. One array should hold the number sequence, and another could keep track of the frequencies of each number. Sample Output #1: What's the highest number you want to generate?: 5 How Long of a number sequence do you want to generate?: 10 Okay, we'll generate 10…
write a (GUI) application that asks a user how many integers to be entered, then stores the integers in an array. Allow the user to enter all or a portion of the total integers. Display the integers from first to last, and then display the integers from last to first. Display the minimum and maximum numbers as well as the total and average of the 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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT