Computers and Technology
Computers and Technology, 02.04.2020 00:42, step35

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.)
Create 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.)
Hint: 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.)
Create an ASCII (or text) file that contains text that will be used as input to your program. Call this file textinput.
Have the output stored in a file called textouput.
Create ifstream and ofstream objects called "infile" and "outfile" respectively.
Include 4 functions for initializing, copying text, counting, and writing the results to a file, respectively.
Initialize the initial array with 0's.
Have the file copying text specifically be able to read a line and output that line. (You may wish to call this file copyText.)
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.)
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.
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.

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 08:00, Leggett8152
What best describes a career pathway in a lodging career? a worker starts out as an amusement attendant, then becomes a recreation worker, and then becomes a gaming worker within five years. a worker starts out as a bell hop, then becomes a night clerk, and then becomes a hotel manager within five years. a worker starting out as a tour guide, then becomes a travel clerk, and then becomes a travel agent within five years. a worker starts out as a server, then becomes a food preparer, and then becomes a head chef within five years.
Answers: 1
image
Computers and Technology, 23.06.2019 03:50, dondre54
Q-1 which of the following can exist as cloud-based it resources? a. physical serverb. virtual serverc. software programd. network device
Answers: 1
image
Computers and Technology, 23.06.2019 08:00, hernandez09297
What is a scenario where records stored in a computer frequently need to be checked
Answers: 2
image
Computers and Technology, 23.06.2019 09:30, Cocco
You have been supporting csm tech publishing's windows server 2016 server network for over a year. the office has two windows server 2016 servers running active directory and a number of other roles. management has informed you that a small sales office is opening in the same building three floors up. the sales manager wants to install a sales application on a server located in the sales office. this server will have limited physical security because there's no special room dedicated for it, which means it will be accessible to non-it personnel and visitors. you're considering installing windows server 2016 server core on the new server because accessing its console regularly probably won't be necessary, and this server will be managed from one of the other csm tech publishing servers. what are the benefits and drawbacks of using server core for this branch office? what are some things you should do to set up this server management environment?
Answers: 1
Do you know the correct answer?
Write a program that reads a given text file, outputs the text file as is, and also prints the numbe...

Questions in other subjects:

Konu
Mathematics, 12.08.2020 07:01
Konu
Mathematics, 12.08.2020 07:01