This website is preserved for historical and scholarly reference and is no longer actively maintained.

Assignment #5

Due Monday, March 29 at midnight.

This individual programming assignment will be accepted up to two class days after the program was due. There will be penalty points deducted as follows.


turned in by midnight Monday, March 29: no points deducted
turned in by midnight Tuesday, March 30: 20 points (total) deducted
turned in by midnight Wednesday, March 31: 40 points (total) deducted
not accepted after midnight Wednesday, March 31

You are to create a new method, readAndProcess, which will read a file and print out the words in the file, one per line. No punctuation is to be printed and all words are to be converted to lower case before printing. In addition, the line number on which the word is found is to be printed before the word and separated from the word by a blank. Create a file called myFileReader.cpp which contains the method readAndProcess.

Expect readAndProcess to be called by a statement of the form: where the file named "fileName" contains a text file.

For example, if fileName contains: The following would be printed: Some introductory file handling is on pages 21-22 of C++ Primer. Additional file handling is covered in Chapter 20. Note especially that if you pass the name of a file to a method you will need to append ".c_str()" to the fileName when you open the file for input (see page 1099).

Compile your program using "g++ user.cpp".

Using the handin command, turn in myFileReader.cpp. Programs that do not compile will receive very little credit.

Use the required style standards .


Return to Eleanor Hare's home page.

Return to Department of Computer Science Home page.