Question: For this program, you are required to write a program that reads words from a dictionary file. The dictionary files are just premade files that
For this program, you are required to write a program that reads words from a dictionary file. The dictionary files are just premade files that contain words separated by whitespace. Your program must scan through the file and then A) write all 3 letter words from the dictionary to a file, B) write all 4 letter words from the dictionary to another file. (The files you write to must be distinct from the dictionary files and also distinct from each other.)
What your program should do:
Prompt the user to enter the name of the dictionary file to use (a text file)
Set up two arrays of Strings, w3[] and w4[] Read all words from the file
store all 3-letter words from the file into w3[]
store all 4-letter words from the file into w4[] Write w3[] into a file called shorts3 Write w4[] into a file called shorts4
You must create and fill the arrays w3[] and w4[] correctly; otherwise points will be deducted.
You may assume that a dictionary file contains a maximum of 20,000 words.
You will need to know how to read and write a text file - we will cover this in class Thursday. The dictionary file used by your program should be in the same directory as your executable.
Your program should work with the dictionary files words5, words5a, words6752 and words10683. All of these dictionary files are accessible through your browser at
http://userwww.sfsu.edu/~whsu/csc210/Projects/P10
(Theres also a very short file, ~whsu/csc210/Projects/P10/words5, for initial testing.)
In more detail, suppose words5 is used to test your program. The program starts reading words5, line by line.
The first word read is cat. This is stored in w3[0]. The next word read is intolerable. This is not stored.
The next word read is dog. This is stored in w3[1].
The next word read is curd. This is stored in w4[0]. Finally, daft is read and stored in w4[1].
The contents of w3[] are written to the file shorts3. The contents of w4[] are written to the file shorts4.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
