Explain initialize variables counting the lines and letters

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

C++, OOP

Write a program that reads a given text file, outputs the text file as is, and also prints the number of lines and the number of times each letter appears in the text file. (To simplify things, treat uppercase letters and lowercase letters as being the same.)

oCreate an array of 26 components to do the letter count for the 26 letters in the alphabet and a variable for the line count. (You may wish to call these variables letterCount and lineCount respectively.)

oHint: Use the plan of declaring variables, opening input and output files, initializing the variables, reading and writing the character for each character in a line, incrementing the letter count, incrementing the line count, outputting line and letter counts and, finally, closing the input and output files. (You may wish to call the program outputting line and letter counts writeTotal.)

oCreate an ASCII (or text) file that contains text that will be used as input to your program. Call this file textinput.

oHave the output stored in a file called textouput.

oCreate ifstream and ofstream objects called and respectively.

oInclude 4 functions for initializing, copying text, counting, and writing the results to a file, respectively.

Af?A??Initialize the initial array with 0's.

Af?A??Have the file copying text specifically be able to read a line and output that line. (You may wish to call this file copyText.)

Af?A??Whenever a nonblank character is found, it calls the function that does the counting, characterCount, to update the letter count.

(Do not count blank, tab, or end-of-line characters as part of the letter count.)

Af?A??Have the characterCount function convert the letter to uppercase, find the index of the array corresponding to this letter and, if the index is valid, increment appropriate count.

Af?A??Have the main program do the following:

Declare variables.

Open the input and output files.

If the input file does not exist, exit the program.

Open the output file.

If the output file cannot open, exit the program.

Initialize variables counting the lines and letters.

Read the first character.

Use while (not end of input file).

Process the next line using the function that reads a line and outputs the line copyText.

Increment the line count. (Increment the variable lineCount.)

Read the next character.

Output the line count and letter counts.

Use writeTotal.

Close files.

Reference no: EM13307756

Questions Cloud

What would programs have to do for each type of hardware : If an applications' requests for data did not go through the OS, what would programs have to do for each type of hardware?
Find maximum distance that these stars could be from earth : Two stars are 2.1 Ã- 1011 m apart and are equally distant from the earth. Find the maximum distance that these stars could be from the earth
What steady-state concentration of co will be observed : If a temperature inversion forms over the city at a height of 0.70 km, how long will it take the carbon monoxide concentration to reach 50 ppm if the wind velocity is zero If the wind velocity is 1 m/s,
Obtain the final speed of the ball : A baseball has a mass of 0.140 kg, and it is pitched towards home plate at a speed of 54.0 m/s. what is the final speed of the ball
Explain initialize variables counting the lines and letters : If the output file cannot open, exit the program. Initialize variables counting the lines and letters. Write a program that reads a given text file, outputs the text file as is, and also prints the number of lines and the number of times each lette..
Find frequency will you observe : A fire truck has a siren with that generates a sound with a frequency of 6686 Hz. what frequency will you observe
Organizations that contribute to the labor relations : Prominent organizations that contribute to the labor relations - aspect of the HR field, so your boss has budgeted funds for you to increase your own expertise.
Determine will h increase or decrease and by how much : an air space above a long tube is pressurized to 50 kPa vacuum. water (20 degrees C) from a reservoir fills the tube to a height h. If the pressure in the air space is changed to 25kPa vacuum, will h increase or decrease and by how much
Find the intensity of the sound at the time of observation : A sound pulse has a power of 948.5 watts. find the intensity of the sound at the time of observation

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Use a switch statement

Use a switch statement to write a program that prompts user to enter an character.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Create a file, shared.txt

When your program starts, it shall do the following:1. Create a file, SHARED.txt, in the current directory (cwd). 2. Write it's pid (Process ID) followed by a Carriage Return and Newline in the file.

  Write a program to create 100 real random numbers

Write a program to create 100 real random numbers and store it into a 1-D array. Find the value 1413 from the stored data and print out the value 1413 and the index of the array to the screen

  Hypothetical method lock over an object lock

Imagine a hypothetical version of Java where the object lock is replaced by a method lock. Under this system a call to a synchronised method would assign a lock for that method to the calling thread.

  Use the getint and getintwithinrange methods

Use the getInt and getIntWithinRange methods to validate that each score ranges from 1 through 100 and add code that discards any extra entries at the prompt that asks if you want to enter another score to the application below.

  Take an n x n matrix, and create a new, (n-1) x (n- 1)

take an N x N matrix, and create a new, (N-1) x (N- 1), matrix with each element being the sum of four nearby elements. You need to figure out a way to break the matrix up into squares and iterate through the matrix, while staying within its bounds.

  Reportingmark a string of 2 to 4 upper case

Declare a structure named: Car containing: reportingMark a string of 2 to 4 upper case characters carNumber an int kind could be box tank flat or other loaded a bool destination a string with a destination or the word NONE Note: A destination is r..

  Your main function will still prompt the user

Your main function will still prompt the user for the account number and service code. Based on the service code, main will ask for the correct number of minutes, then call your functions above as needed to finish the job. In addition you must.

  Create a program that contains 4 methods

Create a program that contains 4 methods / functions... main(), getTestScores(), calcAverage(), and displayAverage(). The main() method should call the getTestScores() method to get and return each of 3 test scores.

  Program that calculates how much a person earns in a month

Write a program that calculates how much a person earns in a month if the salary is one penny the first day, two pennies the second day, four pennies the third day,

  A pattern detector has an input

A pattern detector has an input a 4 x 4 matrix whose elements take values a, b, c, or d. The output is 1 if the matrix contains one b surrounded by eight a's and 0 otherwise.

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