Program to count words and numbers in a plain text file

Assignment Help Computer Engineering
Reference no: EM132194686

Question :

Write a C++ program to count words and numbers in a plain text file. Words and numbers can be repeated.

The input is one text file, with words and integers, separated by any other symbols including spaces, commas, period, parentheses and carriage returns.

Keep in mind there can be be multiple separators together (e.g. many spaces, many commas together).

The input is simple. You can assume a word is a string of letters (upper and lower case) and a number a string of digits (an integer without sign).

Words and numbers will be separated by at least one non-letter or one non-digit symbol.

Length: You can assume one word will be at most 30 characters long and a number will have at most 10 digits. Repeated strings: words and numbers can be repeated.

However, you are not asked count distinct words or compute frequency per word, which require algorithms and data structures to be covered in the course. Therefore, you just simply need to count word or numver occurrences. #include "ArgumentManager.h" int main(int argc, char* argv[]) { if (argc < 2) { std::cerr << "Usage: count filename=input1.txt\n"; } ArgumentManager am(argc, argv); std::string filename = am.get("filename"); std::ifstream ifs(filename.c_str()); std::string line; while (getline(ifs, line)){ // replace symbols by space for line. // ... std::stringstream ss(line.c_str()); std::string str; while (ss >> str) { if (is_number(str)) { // ... } else { // ... } } } return 0; }

Reference no: EM132194686

Questions Cloud

Accurate measure of the standard of living : Is gross domestic product an accurate measure of the standard of living? Why or why not?
Create a 2-dimensional array of 10 by 5 elements : Create a 2-dimensional array of 10x5 elements that are populated by random numbers between 0 and 49.
Medical marijuana laws : In recent years, about twenty states have passed so-called medical marijuana laws. Typically, these laws permit individuals to lawfully purchase marijuana
Legalization of presently illegal substances : Of what significance is the elasticity of demand for drugs in the debate about legalization of presently illegal substances?
Program to count words and numbers in a plain text file : Write a C++ program to count words and numbers in a plain text file. Words and numbers can be repeated.
Supporters of a higher minimum wage : Why do you think organized labor groups, such as unions, are supporters of a higher minimum wage, even though all of their members earn much more
Ask the user to input the number of rows and columns : The program will fill the arry starting at location [0][0] with the user selected starting number and each element after will be incremented by the user direct.
How a change in the exchange rate affected firm : Describe how a change in the exchange rate affected your firm. Explain what happened to your price and quantity.
Elasticity of demand for a given product or services : What are the two primary factors that determine the elasticity of demand for a given product or services?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Why organizations create threat models

In your own words explain why organizations create threat models? 150 Words Research a unique news story or article related to Information Security/Information.

  Questionmake an xml file in visual studio that contains the

questionmake an .xml file in visual studio that contains the exact same information. name files

  Express the movement of the spot on the disk

In the rotating disk and strobe demo, we observed that different flashing rates of the strobe light would make the spot on the disk stand still.

  Describe which cloud architectures you would employ

Cloud Computing Assignment - Your team has been engaged to provide a risk assessment for MetaSoft in their planned move to a Hybrid Cloud strategy

  Modify a module named getnumber

Design a module named getNumber that uses a reference parameter variable to accept an Integer argument. The module should prompt the user to enter a number and then store the input in the reference parameter variable.

  How many draws does it take on average to record k different

Think of an urn with n balls numbered from 1 to n. Sampling with replacement: A ball is drawn, its number is recorded, then the ball is returned.

  Develop a method for configuring and managing a software

Develop a method for configuring and managing a software repository. After creating the solution, search for available version control tools. Select the tool you believe to be the best to implement your solution.

  Develop a site structure diagram using word

Develop a site structure diagram using Word, PowerPoint or any other tool that you feel comfortable with. The top level of hierarchy should only show home page.

  Determine inflation hedge against increasing rates

Read the following letter from a magazine publisher: Dear Parent: Currently your Growing Child/Growing Parent subscription will expire with your 24-month issue.

  Explain the term unicast versus multicast

Explain the Unicast versus multicast, Broadcast versus conference, Channel bandwidth and Network partitioning for multicasting communications.

  Create a game of video poker with a graphical user interface

Create a game of video poker with a graphical user interface (GUI). The player should start with $100, and then the system deals out 5 playing cards.

  Output of convolution

Convolve sub-image shown below with the 3x3 mean filters. Specify the output of convolution at the center entry of sub-image?

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