EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
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
Write a complete Java program named FindSumAndAverage that performs the following tasks in 2-D array: Main Method: a. The main() method asks the user to provide the dimension n for a square matrix. A square matrix has an equal number of rows and columns. b. The main() method receives the value of n and calls the matrixSetUp() method that creates a square matrix of size n and populates it randomly with integers between 1 and 9. c. The main method then calls another method named printMatrix() to display the matrix in a matrix format. d. The main method also calls a method named findSumAndAverage() which: • Receives the generated matrix as input. • Calculates the sum of all elements in the matrix. • Calculates the average value of the elements in the matrix. • Stores these values (sum and average) in a single-dimensional array and returns this array • e. The main method prints the sum and average based on the result returned from findSumAndAverage()). Enter the dimension n for the square…
The partial sums remain the same no matter what indexing we done to s artial sum of each series onverges, * + s of each series to the series or show 12. (1)+(0)+(0)+(+1)+ 17, " (F) + (F) + (F)(F)(- 18. 19. 1 #20. (三)+(三)-(三)+(3) 20 (9)-(0)-(0)-- 10 +1 2.1+(男)+(男)+(罰)+(鄂 9 T29 x222-끝+1-23 + -.... Repeating Decimals 64 Express each of the numbers in Exercises 23-30 as the m integers. 23. 0.23 = 0.23 23 23... 24. 0.234 = 0.234 234 234. 25. 0.7 = 0.7777... 26. 0.d = 0.dddd... where d is a digit natio of own s converges or * 27. 0.06 = 0.06666.. 28. 1.4141.414 414 414... 29. 1.24123 = 1.24 123 123 123... 30. 3.142857 = 3.142857 142857. Using the ath-Term Test In Exercises 31-38, use the ath-Term Test for divergence to show that the series is divergent, or state that the test is inconclusive 8
CPS 2231 Computer Programming Homework #3 Due Date: Posted on Canvas 1. Provide answers to the following Check Point Questions from our textbook (5 points): a. How do you define a class? How do you define a class in Eclipse? b. How do you declare an object's reference variable (Hint: object's reference variable is the name of that object)? c. How do you create an object? d. What are the differences between constructors and regular methods? e. Explain why we need classes and objects in Java programming. 2. Write the Account class. The UML diagram of the class is represented below (10 points): Account id: int = 0 - balance: double = 0 - annualInterestRate: double = 0.02 - dateCreated: java.util.Date + Account() + Account(id: int, balance: double) + getId(): int + setId(newId: int): void + getBalance(): double + setBalance(newBalance: double): void + getAnnualInterestRate(): double + setAnnualInterest Rate (newRate: double): void + toString(): String + getDataCreated(): java.util.Date +…
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