Describe the most fun aspect of the given assignment

Assignment Help C/C++ Programming
Reference no: EM131207643

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.

Reference no: EM131207643

Questions Cloud

Create the tables department employee computer and vehicle : Create the tables DEPARTMENT, EMPLOYEE, COMPUTER, and VEHICLE. Add the primary key field(s) and at least 2 non-key fields to each table that are relevant to that table (ie. PhoneNumber would be valid for EMPLOYEE).
Calculate two ratios first using aspe and then using ifrss : Calculate the two ratios first using ASPE and then using IFRSs. - Prepare a schedule showing any adjustments to the numerator and denominator for these ratios. Ignore income taxes.
Calculate total restaurant sales and sales of each product : Calculate the total restaurant sales and the sales of each product line that would be necessary to achieve the desired target net income
How you personally feel about treating such an individual : Pretend that you are the psychologist who is assigned to treat this individual. Describe in detail some of the instruments/tools that you would use to assess risk and diagnose this individual.
Describe the most fun aspect of the given assignment : Describe 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.
Different integrated marketing tactics : Part 1: Design five (5) different integrated marketing tactics (including graphics and text/copy). The five tactics are as follows:
Transportation forces contribute to understanding : How does understanding a country's ability to generate, transport, and sustain transportation forces contribute to understanding its national power? must be 250 words.
What are some of the steps that tower associates can take : What are some of the steps that Tower Associates can take to help mitigate and manage some of the risk involved if they proceed with the transaction, such as: foreign exchange risk, sovereign risks, liquidity risks, market risks, insolvency, and c..
How is a substance use disorder diagnosed : What category of substances do cocaine and amphetamine fall under, and what are the implications of this category on the body? Be sure to give the classification, DEA schedule, and physical effects.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd