Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that reads from a file specified in the command line as an argument. The program should read from the file words

image text in transcribed
Write a C++ program that reads from a file specified in the command line as an argument. The program should read from the file words until the end of file. In case the file is empty, print out on a new line the message "File is empty." and then exit. However, if no file name is provided, the program should print on a new line "NO SPECIFIED INPUT FILE NAME.", and exit. If the file cannot be opened, print on a new line "CANNOT OPEN THE FILE ", followed by the file name, and exit. A word is defined as a sequence of one or more non-whitespace characters separated by whitespace. Given a list of prepositions, the program should keep a record of the number of occurrences of each preposition in the list that is seen in the input file. The program should create a simple directory using the container for keeping a record of each seen preposition and its occurrences. In this assignment, we consider the following subset of prepositions: ("about", "after", "below", "for", "from", "in", "into", "under", "with"). After all input has been processed, the program should the following: . Print each preposition word in the list that has been seen in the file and the number of its occurrences. The preposition words should be printed in order. . Determine and printout the preposition that has been seen the largest number of times in the file. In case no preposition words from the given list are found in the file, the program should print out the message: "No Preposition words from the given list are found in the file.", then exit. This tool needs to be loaded in a new browser window

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

which file is used to maintain password security

Answered: 1 week ago