Phone Book Errors

need help diagnosing these errors.

Page 1 of 1

3 Replies - 684 Views - Last Post: 10 December 2009 - 06:16 AM Rate Topic: -----

#1 bedrockhorror  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 56
  • Joined: 22-October 09

Phone Book Errors

Posted 09 December 2009 - 10:05 PM

Hey guys, I am getting like 23 errors in this program, and they all relate to "cannot find symbol". Its too many errors to post but I will post a few of them, can you guys please take a look at my program for me, and see why I am getting so many errors.

**RESIDENTIAL PHONE LISTING**
public class residentialPhoneListing
{
 private  String companyName;
 private  String purposeSlashpdept;
 private  String address;
 private  String city;
 private  int  zip;
 private  String state;
 
 private  String lastName;
 private  String firstName;
 private  String middleName;
 
public void setlastName(String currlastName)
{lastName=currlastName;}
 
public void setfirstName(String currfirstName)
{firstName=currfirstName;}
 
public void setmiddleName (String currmiddleName)
{middleName=currmiddleName;}
 
public String getlastName()
{return lastName;}
 
public String getfirstName()
{return firstName;}
 
public String getmiddleName()
{return middleName;}
}



**BUSINESS PHONE LISTING**
public class businessPhoneListing
{
 private  String companyName;
 private  String purposeSlashdept;
 private  String address;
 private  String city;
 private  int zip;
 private  String state;
   
   
public void setcompanyName(String currcompanyName)
{companyName = currcompanyName;}
   
public void setpurposeSlashdept(String currpurposeSlashdept)
{purposeSlashdept  = currpurposeSlashdept;}

public void setcurrAddress(String currAddress)
{address = currAddress;}

public void setcurrcity(String currCity)
{city= currCity;}

public void setcurrState(String currState)
{state = currState;}

public void setcurrzip(int currZip)
{zip = currZip;}

public String getcompanyName()
{return companyName;}

public String getpurposeSlashdept()
{return purposeSlashdept;}

public String getaddress()
{return address;}

public String getcity()
{return city;}

public int getzip()
{return zip;}

public String getstate()
{return state;}
}



**DRIVER FOR THE PHONE BOOK**
import java.io.*;
import java.util.Scanner;
import java.lang.*;
import java.util.*;
public class phoneDriver
{
public static void main (String [] args)
{
residentialPhoneListing res = new residentialPhoneListing ();
int num;
String name;
Scanner keyboard= new Scanner(System.in);
System.out.print("How many listings are you creating ");
num=keyboard.nextInt();
 
while (num>=0)
{
System.out.print("What is your First Name ");
name=keyboard.readString();
res.setfirstName();
res= new residentialPhoneListing(name);
 
System.out.print("What is your Middle Name ");
name=keyboard.readString();
res.setmiddleName();
res= new residentialPhoneListing(name); 

System.out.print("What is your Last Name ");
name=keyboard.readString();
res.setlastName();
res= new residentialPhoneListing(name);
}
 
System.out.print("Residential Phone Listing ");
for(int count =1; count<=num; count++)
{
System.out.println(res.getfirstName() + res.getmiddleName() + res.getlastName() );
}

buslisting bus= new buslisting ();
int num1;
String name1;
Scanner keyboard= new Scanner(System.in);
System.out.print("How many listings are you creating ");
num1=keyboard.nextInt();
 
while (num1>=0)
{
System.out.print("What is your Company Name ");
name1=keyboard.readString();
bus.setcompanyName();
bus = new buslisting (name1);

System.out.print("What is your Purpose/Dept ");
name1=keyboard.readString();
bus.setpurposeSlashdept();
bus = new buslisting (name1);

System.out.print("What is your Address ");
name1=keyboard.readString();
bus.setcurrAddress();
bus= new buslisting(name1);

System.out.print("What is your City ");
name1=keyboard.readString();
bus.setcurrcity();
bus= new buslisting(name1);

System.out.print("What is your State ");
name1=keyboard.readString();
bus.setcurrState();
bus= new buslisting(name1);

System.out.print("What is your Zipcode ");
name1=keyboard.nextInt();
bus.setcurrzip();
bus= new buslisting(name1);

}
 
System.out.print("Business Phone Listing ");
for(int coun=1; coun<=num1; coun++)
{
System.out.println(bus.getcompanyName() + bus.getpurposeSlashdept() + bus.getcity() + bus.getzip ()
+ bus.getaddress() + bus.getstate() );
}
}

}



Here is a few errors that I am getting. If you guys want me to post all 23 then let me know!

phoneDriver.java:34: cannot find symbol
symbol : method readString()
location: class java.util.Scanner
name=keyboard.readString();
^
phoneDriver.java:35: setfirstName(java.lang.String) in residentialPhoneListing cannot be applied to ()
res.setfirstName();
^
phoneDriver.java:36: cannot find symbol
symbol : constructor residentialPhoneListing(java.lang.String)
location: class residentialPhoneListing
res= new residentialPhoneListing(name);
^
phoneDriver.java:39: cannot find symbol
symbol : method readString()
location: class java.util.Scanner
name=keyboard.readString();
^
phoneDriver.java:40: setmiddleName(java.lang.String) in residentialPhoneListing cannot be applied to ()
res.setmiddleName();
^
phoneDriver.java:41: cannot find symbol
symbol : constructor residentialPhoneListing(java.lang.String)
location: class residentialPhoneListing
res= new residentialPhoneListing(name);
^
phoneDriver.java:44: cannot find symbol
symbol : method readString()
location: class java.util.Scanner
name=keyboard.readString();
^
phoneDriver.java:45: setlastName(java.lang.String) in residentialPhoneListing cannot be applied to ()
res.setlastName();
^
phoneDriver.java:46: cannot find symbol
symbol : constructor residentialPhoneListing(java.lang.String)
location: class residentialPhoneListing
res= new residentialPhoneListing(name);

Is This A Good Question/Topic? 0
  • +

Replies To: Phone Book Errors

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2874
  • View blog
  • Posts: 11,032
  • Joined: 15-July 08

Re: Phone Book Errors

Posted 09 December 2009 - 10:21 PM

About your keyboard errors...there is no readLine method. It is actually called nextLine.

Also fix all of these.
res.setfirstName(); // Need a neme between the ( and )
...
res.setmiddleName(); // Same.
..
res.setlastName(); // Same
...
res= new residentialPhoneListing(name); // There is no constructor with a sting 
//argument made yet. By default there is only blank ()'s avalable without creating 
// your own constructor
...


Was This Post Helpful? 0
  • +
  • -

#3 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Phone Book Errors

Posted 09 December 2009 - 10:27 PM

The Scanner class does not have a method called readString()
it has a readNext() and a readNextline() methods
that would fix a few
Was This Post Helpful? 0
  • +
  • -

#4 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2734
  • View blog
  • Posts: 11,516
  • Joined: 20-September 08

Re: Phone Book Errors

Posted 10 December 2009 - 06:16 AM

Sticking to java coding conventions will help you. Note the captialization and constructor parameters especially in the following. Class names being upper case

public class SomeClass {
	private String firstName;

	public SomeClass(String firstName) {
		  this.firstName = firstName;
	}

	public String getFirstName() {
		  return this.firstName;
	}

	public void setFirstName(String firstName) {
		   this.firstName = firstName;
	}
}


This post has been edited by g00se: 10 December 2009 - 06:18 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1