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

  Program to compute the total volume

Write a program to compute the total volume for a number of cylinders. A cylinder may have different values for height and radius.

  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..

  Write a function named dietoss that simulates the tossing

Write a function named dieToss that simulates the tossing of two dice. When you call the function, it should generate two random numbers ranged in 1 to 6 and return the sum of the die's numbers. In the mail program, ask user how many times the dice s..

  Generate a two-dimensional array

Generate a two-dimensional array of integers of 10 rows by 10 columns that contains 100 random numbers between 0 and 9. Print out the array (well formatted) and do the following computations

  Program to generate 100,000 prime numbers

Write a POSIX C/C++ program to generate 100,000 prime numbers. Assume that the program will be run on a computer with 5 CPUs and that your goal is to have this program finish as quickly as possible.

  Prompt the user for 3 sentences of text

Prompt the user for 3 sentences of text. Pass these pieces of text into a function connect() which will connect all three sentences into one long sentence. Pass the combination sentence back to the main program, where it is printed.

  Finish or complete the coding for me because syntax and code

finish or complete the coding for me. because syntax  and codes, so the proram can execute correctly

  Dealerships are awarded the rebate

Dealerships are awarded the rebate on a quarter-by-quarter basis, only for quarters where their actual sales exceeded expected volumes for that quarter. Expected sales volumes for each quarter are as follows:

  Definition of two queues

Write a code in C lenguage for the definition of two queues, one to hold the process in ready state and one to hold the process in waiting state. The queue should be designed to manage a process structure. Please comment the code.

  Reading of coefficients

Reading of coefficients a, b, c shall be done by a function named readCoeffs(). They shall be entered as double's from the keyboard by an operator, after prompt, as follows.

  Undirected graph has scanning tree

undirected graph has scanning trees. The minimal scanning tree is the scanning tree with the minimal sum of weights on edges. The minimal scanning tree can be found by using Prim's algorithm

  Create a base employee class

Create a base Employee class and a derived StudentEmployee class

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