<Project 7 Directions>
Using your favorite text editor, type your solution and save it as a file named Project_07.cpp within your CPE211_FALL18/Project_07 directory. If there are syntax errors, correct them and compile again. Once your program successfully compiles, run it and verify that the output for your modified program matches the output from the solution executable.
NOTE: make sure that you do not change the order in which the information is entered. An automatic script is used to process all lab submissions, and if the order of the input information is modified, the script will not work properly with your program.
<Project 7 Hints>
- Go over the slides for this project
- Run the sample solution (not just the comparison script)
- Use a priming read to read the first character of the input file (outside of outer loop)
- Verify if the input file is empty or not. For an empty input file print out the appropriate message
- Use 2 nested loops to read in the characters.
- The outer loop is looking for the end of the file and is checked on a line by line basis
- The inner loop is reading a line character by character and looking for the new line character that signals the end of the line
- Be careful with the termination of the inner loop when a new line character is read make sure that it is counted in the other category.
- Set up of the nested loop logic is important. Make sure that all characters read are counted and that no characters are skipped. This looping structure requires some thought to be done correctly
- Use the header file cctype to make use of some functions that tell the type of character stored in a char variable. See Below.
- Technically correct programs will have at least 5 header files.
- Use integer variables to hold the counted values. Need two sets of variables to hold the character type counts. One set is for the characters on each line. The other one is for holding the totals of each type of character for the entire input file.
- The sample output is left justified with a field width of 15 for the line number column and 10 for the next 4 columns.
- For an empty input file, the empty input file message only is printed.
- After a new line character is read, the individual line counts are output and the total amounts for the program are updated with the counts from the individual lines.
- Look at the slides for further information on the project
- To reset a file stream variable, place the following statement as shown into your program at the location where you want to reset the stream:
File_stream_var.clear();
Where File_stream_var is the name of the file stream variable you use in your program (i.e. inFile, outFile, etc).
- There are 50 dashes separating the line counts from the totals line
- cctype header file contains the following functions. These functions return true or false values and each requires a character as the argument in the function call o isalpha(charVar) returns true if the character in charVar is a letter o isdigit(charVar) returns true if the character in charVar is a digit(number)
Reviews
There are no reviews yet.