Describe most fun aspect of the assignmentdescribe the most


PA #1: Word Counter

Tabulating basic document statistics is an interesting exercise that leverages your knowledge of strings, files, loops, and arrays. In this homework, you must write a C++ program that asks the user for an input and output file. For each line in the input file, write a modified line containing a line number to the output file. Additionally, calculate the number of paragraphs, lines, words, and characters. Write the summary information to the bottom of the output file.

Program Flow

Your program should operate as follows:

• Prompt the user for an input and output file
• Loop through the input file

o Increment the current line number
o If the line contains only a single newline character (\n), it is considered to be a paragraph. Increment the number of paragraphs
o Add the line's number of characters with spaces, characters without spaces, and word count to the document total.

- To make things simpler, use spaces to determine word boundaries. For example "quick thinking" is two words whereas "quick-thinking" is one.

- Remember to not count newlines '\n' as characters in any circumstances

o Write the current line number plus the line to the output file

• Write the following statistics at the bottom of the output file:

o paragraphs
o words
o characters (not counting spaces)
o characters (counting spaces)
o total lines

Required Functions

In all, you must define and use the following functions:

int get_character_count_with_spaces(string line);

This returns the total number of characters (including spaces) present in the given character array. Be sure not to count newline characters '\n' in this count.

int get_character_count_without_spaces(string line);

This returns the total number of characters (not including spaces) present in the given character array. Be sure to not count newline '\n' characters and spaces ' '.

int get_words(string line);

This returns the total number of words present in the given character array. For simplicities sake, words are defined by spaces. For example "quick thinking" is two words whereas "quick-thinking" is one.

int is_paragraph(string line);

This returns a value of 1 if the current line is a paragraph (only contains a newline '\n') and 0 otherwise.

void parse_file(ifstream input_file, ofstream output_file);

This function accepts input and output files and should be responsible for performing file calculations via the other functions. This is also where you will output the modified document with line numbers.

Sample Output

Your program's output should match the following:
Please enter a file to parse: savio.txt
Please enter a destination file: savio_parsed.txt
Program Complete.

The contents of the outputted file (in this case, savio_parsed.txt) would then look like:

1 We have an autocracy which runs this university. It's managed.
2 We asked the following: if President Kerr actually tried to get something more
3 liberal out of the Regents in his telephone conversation, why didn't he make
4 some public statement to that effect? And the answer we received -- from a
5 well-meaning liberal -- was the following: He said, "Would you ever imagine
6 the manager of a firm making a statement publicly in opposition to his board
7 of directors?" That's the answer! Now, I ask you to consider: if this is a
8 firm, and if the Board of Regents are the board of directors, and if President
9 Kerr in fact is the manager, then I'll tell you something: the faculty are a
10 bunch of employees, and we're the raw material! But we're a bunch of raw
11 material[s] that don't mean to have any process upon us, don't mean to be made
12 into any product, don't mean to end up being bought by some clients of the
13 University, be they the government, be they industry, be they organized labor,
14 be they anyone! We're human beings!
15
16 There is a time when the operation of the machine becomes so odious, makes you so
17 sick at heart, that you can't take part; you can't even passively take part,
18 and you've got to put your bodies upon the gears and upon the wheels, upon the
19 levers, upon all the apparatus, and you've got to make it stop. And you've got
20 to indicate to the people who run it, to the people who own it, that unless
21 you're free, the machine will be prevented from working at all!

paragraphs: 1
words: 271
characters (no spaces): 1206
characters (with spaces): 1457
total lines: 21

Test Cases

You have been provided with two test cases (savio.txt / savio_parsed.txt; kennedy.txt / kennedy_parsed.txt). Note I am allowing a tolerance of 10% from my results per statistic so your results don't have to be 100% spot-on.

C++ File, Header Comment, and Formatting

1. Be sure to modify the file header comment at the top of your program to indicate your name, student ID, completion time, and the names of any individuals that you collaborated with on the assignment.

2. Remember to follow the basic coding style guide. For a list of basic rules, see my website or examine my example files from previous assignments and labs.

Reflection Essay

In addition to the programming tasks listed above, your submission must include an essay that reflects on your experiences with this homework. This essay must be at least 350 words long. Note that the focus of this paper should be on your reflection, not on structure (e.g. introductory paragraph, conclusion, etc.). The essay is graded on content (i.e. it shows deep though) rather than syntax (e.g. spelling) and structure. Below are some prompts that can be used to get you thinking. Feel free to use these or to make up your own.

• Describe a particular struggle that you overcame when working on this programming assignment.
• Conversely, describe an issue with your assignment that you were unable to resolve.
• Provide advice to a future student on how he or she might succeed on this assignment.
• Describe the most fun aspect of the assignment.
• Describe the most challenging aspect of the assignment.
• Describe the most difficult aspect of the assignment to understand.
• Provide any suggestions for improving the assignment in the future.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Describe most fun aspect of the assignmentdescribe the most
Reference No:- TGS01591389

Now Priced at $70 (50% Discount)

Recommended (97%)

Rated (4.9/5)