REVscene - Vancouver Automotive Forum


Welcome to the REVscene Automotive Forum forums.

Registration is Free!You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! The banners on the left side and below do not show for registered users!

If you have any problems with the registration process or your account login, please contact contact us.


Go Back   REVscene Automotive Forum > Vancouver LifeStyles (VLS) > Computer Tech, Gaming & Electronics

Computer Tech, Gaming & Electronics THIS SPACE OPEN FOR ADVERTISEMENT. YOU SHOULD BE ADVERTISING HERE!
Silicon Valley.
Tips & tricks, tech support, home theatre, online gaming, reviews, latest news...

Reply
 
Thread Tools
Old 11-12-2013, 09:51 AM   #1
My dinner reheated before my turbo spooled
 
Join Date: Feb 2011
Location: Vancouver
Posts: 1,745
Thanked 691 Times in 275 Posts
Need help with Java, arrays & strings & File I/O.

Anyone knowledgeable with the language Java? I need help with writing a program that got to do with arrays & strings & File I/O.

You have been asked to read a text file word by word, and then sort the words in alphabetical order, and save them in sorted order in another file with following specifications:

1. Prompt user to input for file names.
2. Estimate the number of the words in the file, and then create an array of String such as String[] words = new String [ESTIMATED_SIZE] and store words in the array.
3. Change all world to lower case.
4. If words have a punctuation symbol in the beginning or at the end of the words, then remove the punctuation marks from the word, and keep the word.
5. You need to remove the following punctuation marks from each word; [ '.' (dot), ',' (comma), ';' (semi-colon), ':' (colon), '?' (question mark), '!' (exclamation), ' " ' (double quotation), ' \' ' (single quotation) , ')' (opening parentheses) , and '(' (closing parenthesis )].
6. If words still have any symbol except '-' (hyphen), then ignore the words.
7. Get rid of the words that contain digits.
8. Get rid of spaces from both side of the words.
9. Save the file in unique order. If there are many occurrences of the same word, then save only one of isntance of the word.


Check the sample input file and output file.
Advertisement

Last edited by Recon604; 11-12-2013 at 10:20 AM.
Recon604 is offline   Reply With Quote
Old 11-12-2013, 11:27 AM   #2
RS has made me the bitter person i am today!
 
ForbiddenX's Avatar
 
Join Date: Oct 2006
Location: YVR
Posts: 4,518
Thanked 1,275 Times in 434 Posts
Do you have any progress done or specific questions? I can try and help. Probably won't be learning too much if you're just given the answers though :P
ForbiddenX is offline   Reply With Quote
Old 11-12-2013, 12:39 PM   #3
My dinner reheated before my turbo spooled
 
c_loke's Avatar
 
Join Date: Aug 2002
Location: Richmond
Posts: 1,706
Thanked 10 Times in 7 Posts
Try breaking the problem down a bit. I'll take #2 for example.

You know that you have to get the works into a string array but to do this you first need to get the string of words. The string of words will need to come from somewhere, and in your case, it will come from a file. You then need to figure out how to read a text file to string.

How to create a Java String from the contents of a file? - Stack Overflow

First google search btw.

After you read in the file, you need to determine how you are going to split the words. Well you might want to split on the sentences, so you might have something that says

String [] words = stringofwords.split(" ");
c_loke is offline   Reply With Quote
Old 11-12-2013, 01:08 PM   #4
My dinner reheated before my turbo spooled
 
Join Date: Feb 2011
Location: Vancouver
Posts: 1,745
Thanked 691 Times in 275 Posts
Quote:
Originally Posted by ForbiddenX View Post
Do you have any progress done or specific questions? I can try and help. Probably won't be learning too much if you're just given the answers though :P
only got the part to read the input for file

Quote:
Originally Posted by c_loke View Post
Try breaking the problem down a bit. I'll take #2 for example.

You know that you have to get the works into a string array but to do this you first need to get the string of words. The string of words will need to come from somewhere, and in your case, it will come from a file. You then need to figure out how to read a text file to string.

How to create a Java String from the contents of a file? - Stack Overflow

First google search btw.

After you read in the file, you need to determine how you are going to split the words. Well you might want to split on the sentences, so you might have something that says

String [] words = stringofwords.split(" ");
perfect! ill try to write it. Any of you are expects with java?
Recon604 is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -8. The time now is 12:28 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
SEO by vBSEO ©2011, Crawlability, Inc.
Revscene.net cannot be held accountable for the actions of its members nor does the opinions of the members represent that of Revscene.net