Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

plz reply as soon as possible

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Implement an Object called AddressReader that will be able to open and read the file entitled AddressBook.dat.
AddressBook.dat
1.John Smith 123 Main St. Laurel MD 20708
2.Greg F. Jones 1145 Technology Rd. New York NY 45456
3.Tim Roberts 1324 Basswood Dr. Arlington VA 20166
.
.
.
.
File Format Rules

Position number followed by a .
Full name either first name and last name or first name, middle initial with a . and last name
Address- Street number, Street name, and either Dr, St, or Rd which always ends with a .
City - 1 or more words
State - 2 letter abbreviation
Zip - 5 number code
Class AddressReader will need to have the following functions
int getTotalEntries( );
String getName(int position) - returns the name as a String according to the position provided in the parameter.
String getAddress(int position)
String getCity(int position)
String getState(int position)
String getZip(int position)
There will be a Class Client that has its own main and will instantiate an AddressReader and call its methods.
class Client {
public static void main(String[] args) {
AddressReader add = new AddressReader();
for (int i=0;i<add.getTotalEntries(); i++){
String name = add.getName(i);
String address = add.getAddress(i);
String city = add.getCity(i);
String state = add.getState(i);
String zip = add.getZip(i);

int entry = i+1;
//prints out the contents of AddressBook.dat
System.out.println("Address Entry: "+ entry);
System.out.println("_______________");
System.out.println("Name: "+ name);
System.out.println("Address: "+address);
System.out.println("City: "+city);
System.out.println("State: "+state);
System.out.println("Zip: "+zip);
}
the question is as follows??

If the "position=1"for name and position is 2 for address... then the output should be John Smith and 1145 Technology Roadthe question is as follows??the question is as follows??
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This appears (strangely) to be a repost of the thread here:
https://coderanch.com/t/275805/Streams/java/Java-File-Reading
I'm closing this one.
Dave
 
    Bookmark Topic Watch Topic
  • New Topic