Assignment 2
LOOK AT THE BOTTOM OF THIS PAGE FOR UP-TO-DATE INFORMATION
Modifying the CountFile program
Follow these steps to complete this assignment:
- Download the CountFile source code. This is the same as the listing on page 586 of the text.
- Download this test file.
- Make sure the program works by compiling it and running it to read the text file.
- Modify the program so that it does not count any spaces in the input file. Test your changes on the same test file.
- Modify the program to count the number of upper case letters in the input file and to report both the total number of characters (without spaces) and the number of upper case letters..
You will need the following concepts to complete the task:
- Character literals (look at the example on page 63)
- ' '
: the space character
- conversion of primitive numeric types (casting)
- the equality operator (page 53)
- calling the class method isUpperCase of the class Character (page 115)
Deliverables
Hand in a print of your source code, and the results of the three runs (the original program, ignoring newlines and the vowel counts).
Assignment Due
Monday, 15th September, in class.
LATEST INFORMATION
- To download the source code files and test files successfully do this:
1. In the Netscape browser, just click on the link to the source code file or the test file. This will bring up the file in the browser window.
2. Choose Document Source from the View menu. This will bring up the page in the Simple Text editor.
3. Save the file from the editor into the Student folder.
This sequence handles the end-of-line problem in converting from Unix to Mac.
- Each Mac is now set up with an alias for the student folder for the Java Runner. So when you type in a file name to the command line dialog, you need only type Student/filename.txt instead of the complet pathname.