• Post Reply 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

Name Generator

 
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need some help. I am suppose to write a program that takes three files, one has male first names, another one has female first names and the last file has onyl last names. First we are suppose to read the two files containing the fist names into accessible data structure. Then we take that and we use the last name file to generate last names for the first names we already have. We cannot use a Stringtokenizer. Any help would be appricated. Just a hint to get me started. Anything at all please.

Victoria
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at java.io? Which part are you having trouble with?
 
Victoria Preston
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not know how to get started. It just sounds extremely complicated.
 
Victoria Preston
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the one phrase that has me really confused in "accessible data structure". What it that?
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would start by getting a connection to the file, parsing the contents and putting it in a data structure. There's three steps right there, do you know how to do any of them?
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Victoria Preston:
the one phrase that has me really confused in "accessible data structure". What it that?



I would think they're talking about a data structure you can hold the names in. That would almost certainly take the form of a java.util.Collection, though I purposely leave the exercise of figuring out which type of Collection or better yet which specific implementation to you.
 
Victoria Preston
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ken Blair:
I would start by getting a connection to the file, parsing the contents and putting it in a data structure. There's three steps right there, do you know how to do any of them?



No I don't
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Victoria Preston:


No I don't



Victoria,

The JavaRanch is a site for learning. The community can't help you if you don't provide enough details. Just what don't you understand? Try to be as specific as possible. What have you done so far? Showing some code will be nice.

The last part is very important -- as it is against the rules to provide direct answers to homework problems. We can help you with understanding code, debugging code, or even provide some hints...

Henry
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then I suppose I would start with something as simple as creating a Collection and adding something to it. There's a trail on collections here:

http://java.sun.com/docs/books/tutorial/collections/index.html

A very simple example of creating a Collection and adding something to it.


[ September 11, 2006: Message edited by: Ken Blair ]
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Henry Wong:


Victoria,

The JavaRanch is a site for learning. The community can't help you if you don't provide enough details. Just what don't you understand? Try to be as specific as possible. What have you done so far? Showing some code will be nice.

The last part is very important -- as it is against the rules to provide direct answers to homework problems. We can help you with understanding code, debugging code, or even provide some hints...

Henry



It would seem Victoria doesn't yet understand how to do any of the things I mentioned.
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ken Blair:
I would start by getting a connection to the file, parsing the contents and putting it in a data structure. There's three steps right there, do you know how to do any of them?



Let's start with the first item. How to read a file...

I am pretty sure an example was provided in class -- but let's revisit it anyway. Do you remember the java.io package? How to open a file? Read a line? etc. Don't worry about parsing and putting it in a datastructure yet -- can you just write a method to open the names file, read the lines, and print it out?

Henry
 
Victoria Preston
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry if I have mislead you. I have wrote programs that have have read info from a file and the output to another file. My problem is actually starting it. What the first thing I should do is?
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Henry will have better advice than myself so I'm tapping out, too many hands in the pot and all that.
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Victoria Preston:
I'm sorry if I have mislead you. I have wrote programs that have have read info from a file and the output to another file. My problem is actually starting it. What the first thing I should do is?



Use that program as an example. Write another program that reads info from a file -- and prints (System.out.println()) it out for now. It should read the three names files.


When you finish that, examine what collection classes have you learned in school. (ie. the classes in the java.util package) Do you remember how to put strings into the collections? And then... can you modify the program you did so far to put the names into the collection, instead of printing it out?


If you run into any problems, just come back here -- and provide the code that you done so far, with questions that you are having.

Henry
reply
    Bookmark Topic Watch Topic
  • New Topic