Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C++ whose main function is merely a collection of variable declarations and function calls. This program reads a text and outputs

Write a program in C++ whose main function is merely a collection of variable declarations and function calls. This program reads a text and outputs the letters, together with their counts, as explained below in the function printResult. (There can be no global variables! All information must be passed in and out of the functions. Use a structure to store the information.) Your program must consist of at least the following functions:

  • Function openFile: Opens the input and output files. You must pass the file streams as parameters (by reference, of course). If the file does not exist, the program should print an appropriate message ("The input file does not exist.") and exit. The program must ask the user for the names of the input and output files.

  • Function count: Counts every occurrence of capital letters A-Z and small letters a-z in the text file opened in the function openFile. This information must go into an array of structures. The array must be passed as a parameter, and the file identifier must also be passed as a parameter.

  • Function printResult: Prints the number of capital letters and small letters, as well as the percentage of capital letters for every letter A-Z and the percentage of small letters for every letter a-z. The percentages should look like this: "25%".This information must come from an array of structures, and this array must be passed as a parameter.

Your program should prompt the user for name of the input file, then the name of the output file.


 
 Here is the text file. 

Today we live in an era where information is processed, almost, with the speed of light. Through computers, the technological revolution is drastically changing the way we live and communicate with each other. Terms such as Internet, which was unfamiliar even a few years ago, are very common today. With the help of computers you can send letters to and
receive letters from loved ones within seconds. You no longer need to send an application by mail to apply for a job; in many cases you can simply submit your job application via the Internet. You can watch how stocks are performing in real time, and instantly buy and sell. Kids in elementary school regularly surf the Internet and use computers to design
their classroom projects. Students no longer type their papers on typewriters or write them by hand. Instead, they use powerful word processing software to complete term papers.
Many people maintain and balance their checkbooks on computers. These are some of the ways computers have greatly impacted our daily lives. However, all this is made possible because of the availability of different software, which are computer programs. For example, word processing software are programs that enable you to create term papers, create impressive looking resumes, and even write a book. Even this book was created with the help of a powerful word processor. Without software a computer is of no use. However, software are developed with the help of some programming languages. Moreover, the programming language C++, especially, is very well suited for developing software to accomplish a specific task. Until the early 1990s, before beginning to teach a programming language course, instructors used to spend the first few weeks just to teach their students how to use computers. Today, by the time students' graduate from high school, they know very well how to work with a computer. This book is not concerned with explaining how to use computers. Rather, the main objective is to teach how to write programs in a language called C++. It is useful, however, to at least understand some of the basic terminology and different components of a computer before you begin programming. This chapter briefly describes the main components of a computer system, the history of computer languages, and some fundamental ideas about how to solve problems with computer programming.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

C program that meets the requirements provided include iostream include fstream include cstring using namespace std struct LetterCount int uppercaseCo... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Matlab An Introduction with Applications

Authors: Amos Gilat

5th edition

1118629868, 978-1118801802, 1118801806, 978-1118629864

More Books

Students also viewed these Programming questions

Question

Discuss the roles of metacognition in learning and remembering.

Answered: 1 week ago