
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...

Want to see the full answer?
Check out a sample textbook solution
- THIS IS NOT A GRADING ASSIGNMENT: Please only do lab 2.2 (bottom part of the first picture) For that Lab 2.2 do: *Part 1 (do the CODE, that's super important I need it) *Part 2 *Part 3 I also attached Section 2.5.2 which is part of the step 1 so you can read what is it about. Thank you!arrow_forwardTHIS IS NOT A GRADING ASSIGNMENT: Please only do lab 2.2 (bottom part of the first picture) For that Lab 2.2 do: *Part 1 *Part 2 *Part 3 I also attached Section 2.5.2 which is part of the step 1 so you can read what is it about. Thank you!arrow_forwardcan you please give me: * the code (step 3) *the list file (step 5) *and answer step 6 Thank youarrow_forward
- # Find the error# Why will the following code not print out a list of contact namesphoneBook = {'Doe, Jane' : '843-000-0000' ,'Doe, John' : '843-111-1111' ,'Smith, Adam' : '843-222-2222' ,'Jobs, Steve' : '999-333-3333' ,}for contact in phoneBook.values():print(contact)arrow_forward# Find the error:# The following code creates an empty dictionary and attempts to add a record# Why will the following code not create a new dictionary entry as intended?phoneBook = {}phoneBook{'Jobs, Steve'} = '999-111-1111'arrow_forwardSelect all the possible polar representations of the vector that is obtained from rotating where by Zrot Ź x = 3e² T= 3п 8 Hint: Consider the negative angle that is equivalent to the positive angle of the rotated vector. 0arrow_forward
- Character Analysis If you have downloaded the source code you will find a file named text.txt on the Chapter 08 folder. Write a program that reads the file's contents and determines the following: The number of uppercase letters in the file The number of lowercase letter in the file The number of digits in the file The number of whitespace characters in the filearrow_forwardWrite a program that reads the text file's contents and calculates and outputs the following in this order: • The number of words in the file • The number of lines in the file • The number of uppercase letters in the file • The number of lowercase letters in the file • The number of digits in the file • The number of letter H's in the file • The number of whitespace characters in the file NOTE: Your program should include at least one try-except error handling statement block. Your program should also validate any input that could cause your program to crash. I'm Henery The Eighth, I Am! Henery The Eighth, I Am, I am!I got married to the widow next door,She's been married seven times before.And ev'ryone was a Henery,She wouldn't have Willie or a Sam.I'm her eighth old man named Henery,Henery the Eighth, I Am!Second verse same as the first!I'm Henery The Eighth, I Am! Henery The Eighth, I Am, I am!I got married to the widow next door,She's been married seven times before.And…arrow_forwardFigure 4-40 Modern Database Management, 13th edition, question 4-53arrow_forward
- Which of the following needs improvement in the dashboard shown? A. Instructional clarity missing for the views B. Filter placed at the top of the dashboard C. Inconsistent use of colors to represent missed goals D. Dashboard title too largearrow_forwardIf we click Show dashboard title in this dashboard, what will the title be?arrow_forwardPlease draw the diagram where it is asked to be drawn. Don't just describe how to do it.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning




