Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that creates a simple directory for the occurrences of printable characters read from an input file. The program should read from

Write a C++ program that creates a simple directory for the occurrences of printable characters read from an input file. The program should read from a file name specified in the command line as an argument, However, if no file name is provided, the program should print on a new line "No file is found", and exit.If the file cannot be opened, print on a new line "File cannotbe opened: ",followed by the filename, and exit.The program should read from the file wordsuntil the end of file.If the input file is empty, print out on a new line themessage "File is empty."and then exit.A word is defined as a contiguous number of non-whitespace characters separated by whitespace.The program should keep a record of the number of occurrences of each letter, decimal digit (0-9), and any non-alphanumeric characters (e.g., ., ,, @, etc.)in a directorybuilt using the container. In order to avoid counting uppercase and lowercase letters, all lettersshould be converted to uppercase.After all input has been processed,the program shouldPrint each decimal digit and letterthat was seen the largest number of times on a line by itselfand the number of times it was seen in the file. Print each printable characterread from the file and the number of times it was seen. The charactershould be printed in order.Print the number of non-alphanumeric characters that were seen in the file.

For example, with an input file of the following contents:The results are as shown below: Digits of Largest number of occurrences: 0:8

Digits of Largest number of occurrences: 7: 8

Letters of Largest number of occurrences: E: 43

List of characters seen in the file and their number of occurrences:": 2

(: 1

): 1

,: 7

-: 9

.: 5

0: 8

1: 3

3: 3

6: 3

7: 8

8: 4

9: 2

:: 1

A: 37

B: 17

C: 21

D: 18

E: 43

F: 9

G: 5

H: 23

I: 29

J: 1

K: 6

L: 11

M: 3

N: 26

O: 29

P: 11

Q: 1

R: 28

S: 35

T: 28

U: 15

V: 1

W: 1

Y: 4

Number of non-alphanumeric characters seen in the file: 7

Use functionssuch as: isdigit(), isalpha(),isspace(), and toupper().2.Include the container.3.Create a directory using to map a character to an integer.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago