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

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 05:10
Read the code below. what will the computer print if the input for year_variable is 1700? if year_variable == 1776: print("your answer is correct. the declaration of independence was signed in “year_variable”.") elif year_variable < 1776: compute_variable = 1776 - year_variable. print("add “compute_variable“ years to your answer for the correct answer.") elif year_variable > 1776: compute_variable = year_variable - 1776 print("subtract “compute_variable” years from your answer for the correct answer.")
Answers: 1
question
Computers and Technology, 22.06.2019 22:20
Avariable of the data type arrays is storing 10 quantities. what is true about these quantities? a. the quantities all have different characteristics. b. the quantities all have the same characteristics. c. five quantities have the same and five have different characteristics. d. it is necessary for all quantities to be integers. e. it is necessary for all quantities to be characters.
Answers: 2
question
Computers and Technology, 22.06.2019 22:30
Alex’s family members live in different parts of the world. they would like to discuss the wedding plans of one of their distant relatives. however, alex wants all the family members to talk to each other simultaneously so that they can make decisions quickly. which mode of internet communication should they use? a. blog b. email c. wiki d. message board e. instant messaging
Answers: 2
question
Computers and Technology, 23.06.2019 01:50
Write a program that uses a random number generator to generate a two digit positive integer and allows the user to perform one or more of the following operations: a. double the number. b. reverse the digits of the number. c. raise the number to the power of 2, 3, or 4. d. sum the digits of the number. e. if the number is a two-digit number, then raise the first digit to the power of the second digit. f. if the number is a three-digit number and the last digit is less than or equal to 4, then raise the first two digits to the power of the last digit. after performing an operation if the number is less than 10, add 10 to the number. also, after each operation determine if the number is prime. each successive operation should be performed on the number generated by the last operation. your program should not contain any global variables and each of these operations must be implemented by a separate function. also, your program should be menu driven. 7. (fraction calculator) write a program that
Answers: 1
You know the right answer?
Write a program that reads a given text file, outputs the text file as is, and also prints the numbe...
Questions
question
Business, 06.11.2020 21:10
question
Advanced Placement (AP), 06.11.2020 21:10
question
Mathematics, 06.11.2020 21:10
question
Mathematics, 06.11.2020 21:10
question
Mathematics, 06.11.2020 21:10
question
Mathematics, 06.11.2020 21:10
Questions on the website: 13722367