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

  Machine that i would like to know

Let's say I have a machine that I would like to know, on average, how much it runs throughout a given day through a percentage value. Every 30 seconds, I will have a device to record the current temperature of the machine. If the machine increases..

  Write c program for linked list applications

Write a complete C program which illustrates the Linked list applications data structures and algorithms. The program will read in mid-semester test scores as Main Linked List and produce six outputs:

  Design a simple atm service kiosk

Design a simple ATM service kiosk. This kiosk supports the following options for its menu: 1. Viewing your account balance2. Depositing cash3. Withdrawing cash

  To reverse the order of elements on a stack

Write a program in C++ to  reverse the order of elements on a stack S using two additional stacks using one additional stack

  Chess program, enable a monitoring component

Given a chess program, enable a monitoring component to switch planning algorithms at runtime, based on the opposing player's style and response time.

  Write a c++ program that prompts the user for a double

Write a C++ program that prompts the user for a double that is either positive or negative.

  Write application to calculate price of carpeting for room

The Westfield Carpet Company has asked you to write an application that calculates the price of carpeting for rectangular rooms.

  Write test program to call function several times for gcd

Greatest common divisor of two integers is largest integer which will evenly divide both integers. Implement this function in assembly language and write test program which calls function several times, passing it different values.

  The fibonacci sequence

In the novel "The DaVinci Code", a scrambled version 13, 3, 2, 21, 1, 1, 8, 5 of the first eight Fibonacci numbers appear as one of the clues left by murdered museum curator Jacques Sauniere. In this assignment, we will do something related to t..

  Write a program in c that will find smallest value

Write a programe c that will find the smallest, largest and average values in a collection of N numbers.Get the value of N before scanning each value in the collection of N numbers.

  The function should accept the future value

The function should accept the future value, annual interest rate, and number of years as arguments. It should return the present value, which is the amount that you need to deposit today. Demonstrate the function in a program that lets the user expe..

  C program to compute parking fare for customers

Write C program to compute parking fare for customers who park their cars in parking lot when following information is provided: A character showing type of vehicle: C for car, B for bus and T for truck

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