need some homework help in Java

MATT DAMON

Blue Belt
@Blue
Joined
Jun 10, 2015
Messages
552
Reaction score
0
I have a text file that I need to read.

The text file has full name, middle initial, DOB, sex, and city born.

I need to output the file.

What is the best way for me to process the file?

Do I create a person object? I think I should create the object, but then, I don't know where to store it.

Any ideas?
 
Have you checked whether your computer is plugged in?
 
oh man, I posted to the wrong forum...these replies are hilarious...I should post more homework questions just for laughs...
 
your description is tremendously vague

'output' how? to the screen? to a file? formatted a particular way? do you need to sort or process the records?
 
Have you asked a literate person to read the text file to you?
 
your description is tremendously vague

'output' how? to the screen? to a file? formatted a particular way? do you need to sort or process the records?

I need the output to the screen.

I just need it formatted in this way:

Name, DOB, Sex, Address.

I think I need to process the records, but I don't know how to do it correctly.

I would like to sort them, but how do I sort them? Do I treat the files as one big object, or sort them individually?
 
obviously you should be using what you're being taught in class, but there are a ton of ways to do this

i'm assuming the file is a csv or similar

the simplest would just be to read each line, split into an array, and then print out the line with the array positions hard coded

if you want to go fully fancy, create a person object with a constructor that takes the line and has comparator and print functions and add them to an arraylist, then you can sort the arraylist like so:
http://stackoverflow.com/questions/10082123/using-comparator-to-order-arraylist-java
 
obviously you should be using what you're being taught in class, but there are a ton of ways to do this

i'm assuming the file is a csv or similar

the simplest would just be to read each line, split into an array, and then print out the line with the array positions hard coded

if you want to go fully fancy, create a person object with a constructor that takes the line and has comparator and print functions and add them to an arraylist, then you can sort the arraylist like so:
http://stackoverflow.com/questions/10082123/using-comparator-to-order-arraylist-java

Holy crap, dude! I was on stackoverflow earlier, and couldn't find what I wanted. This is what I was looking for, lol.

I posted on sherdog because I was desperate to solve this Java problem, lol.

Much thanks!!!!!
 
Here you go:

good-will-hunting-5.jpg
 
I need the output to the screen.

I just need it formatted in this way:

Name, DOB, Sex, Address.

I think I need to process the records, but I don't know how to do it correctly.

I would like to sort them, but how do I sort them? Do I treat the files as one big object, or sort them individually?

Assuming the file is delimited in some way (most likely comma or tab), you need to create a file object, read it line by line, split each line by the delimiter, and then print each item from the array. If you're being asked to create objects with these attributes, you need to define a 'person' class with these objects and then for each line set the attributes of the object to the values contained in the string.

Make sure you're importing the io library (if you're using a good IDE it will probably be done automatically). I haven't worked with Java in some time but your task sounds like some variant of this.
 
Back
Top