Forums Register Login

Read the records from the ArrayList

+Pie Number of slices to send: Send
Hi Java masters,

I'm facing some difficulties with a java quizz.
Please give me some ideas.


--------------------------------------------------
Quiz01 :

The text file has three records like :

John
NO.123, HirLet Road,LL 234
025-5-5455
1 5 0 2 7000
Paul
NO.23, Hello Road,LL 235
025-5-5454
1 5 0 2 6000
Mary
NO.23, Mine Road,LL 235
23-5-5454
1 5 0 2 9000



According to the above info, we know the file has John's related record and Paul's related one, and Mary's related one.7000,6000 and 9000 are their respective salaries.

For each record,create an object and add it to ArrayList.
Having created all objects, write those objects to a binary where those whose salaries are over 6000.

Again, display the name of them.

-----------------------------------------------



For the above,


� Do I have to implement StringTokenizer() to make apart each person ?
If so,how ? I guess each record span four lines. So I cut out four lines for each record ?

� How can I compare their salaries ?
To do so,I think I have to use StringTokenizer again.
+Pie Number of slices to send: Send
You could use StringTokenizer, althought that is now deprecated.

Why not use a java.util.Scanner to read and parse the lines and data from the files?
You did say they are simple text files, didn't you?

I have never used a Comparator, but you can probably get it to produce a compare() method which works on salaries, then you can use a method like sort() in the java.util.Arrays class or the java.util.ArrayList class.

And if you win the quiz, can I share the prize?

CR
+Pie Number of slices to send: Send
Thank you.

Just a quizz in a school textbook
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1243 times.
Similar Threads
Locking Schemes: Tactical View 01
URLyBird GUI MVC <-> Business Layer in a Thin Client and HashMap vs. ArrayList
search algorithm: clarity and efficiency
including javascript code in JSP
removing duplicates usig set
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:52:57.