still get these error messages: C:\Users\thorunn\Documents\NetBeansProjects\PhoneBook\src\TestPhoneBook.java:25: error: illegal start of expression public static void main(String[] args) { C:\Users\thorunn\Documents\NetBeansProjects\PhoneBook\src\TestPhoneBook.java:25: error: illegal start of expression public static void main(String[] args) { C:\Users\thorunn\Documents\NetBeansProjects

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I still get these error messages:

C:\Users\thorunn\Documents\NetBeansProjects\PhoneBook\src\TestPhoneBook.java:25: error: illegal start of expression
public static void main(String[] args) {
C:\Users\thorunn\Documents\NetBeansProjects\PhoneBook\src\TestPhoneBook.java:25: error: illegal start of expression
public static void main(String[] args) {
C:\Users\thorunn\Documents\NetBeansProjects\PhoneBook\src\TestPhoneBook.java:25: error: ';' expected
public static void main(String[] args) {
C:\Users\thorunn\Documents\NetBeansProjects\PhoneBook\src\TestPhoneBook.java:25: error: '.class' expected
public static void main(String[] args) {
C:\Users\thorunn\Documents\NetBeansProjects\PhoneBook\src\TestPhoneBook.java:25: error: ';' expected
public static void main(String[] args) {
C:\Users\thorunn\Documents\NetBeansProjects\PhoneBook\src\TestPhoneBook.java:43: error: reached end of file while parsing
}
6 errors

After correction of TestPhoneBook

package PhoneBook;

import java.util.Scanner;


public class TestPhoneBook {

// lookupName method that return the target phone number
public static String lookupName(String targetName, PhoneBook anArray[])
{
String targetPhoneNumber="";

boolean result=false;
// checking the name with lookupName
for (int idx = 0; idx<anArray.length && !result; idx++)
{

if(anArray[idx].getName().equalsIgnoreCase(targetName))
{
targetPhoneNumber = anArray[idx].getPhoneNumber();
result=true;
}
}

// return targetPhoneNumber
return targetPhoneNumber;

}

public static void main(String[] args) {

Scanner kbd = new Scanner(System.in);

PhoneBook[]arrObj = new PhoneBook[3];

arrObj[0]= new PhoneBook("John Ficks", "657-9875");
arrObj[1]= new PhoneBook("Howard Williams", "908-1001");
arrObj[2]= new PhoneBook("George Clemens", "808-5001");

System.out.println("Enter name to look up");

String targetName = kbd.nextLine();

String targetPhone = lookupName(targetName, arrObj);

System.out.println("The phone number is "+targetPhone);

}

}

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY