Question: IN c++ This program is part of a larger programming project. For this one part all that is needed is to idenetify the errors in
IN c++
This program is part of a larger programming project. For this one part all that is needed is to idenetify the errors in the command line arguments being passed. below Everything in Bold is a command line argument that is being passed. Each is a seperate case.
noargs:
len0: 0 lenxxx: xxx modexxx: 1 xxx modeall: 1 all modetop: 1 top onefile: 1 all emptyfile badfile: 1 all nonexistantfile emptyfile manyfile: 1 all emptyfile nonexistantfile emptyfile emptyphrase: 1 all emptyfile oneword: 1 all onewordfile onewordtwice: 1 all onewordtwicefile twowords: 1 all onewordfile onewordtwicefile manywords: 1 all manywordsfile mustlowerone: 1 all upperword mustlowermany: 1 all mixedword allmodecomplete: 1 all constitution wordfreqsame: 1 all samefreq phraselen2: 2 all manywordsfile topmode: 1 top manywordsfile phraselen3: 3 top manywordsfile phrasefreqsame: 3 top samefreq topmodecomplete: 3 top fullconstitution
so 3 top fullconstitution and 1 all onewordfile are two different command line arguments. being passed separately.
In bold are arguments to be passed, in different test cases
Since this project is part of larger one, i want to take care of all the possible errors
You must detect the case where no arguments are passed. In that case, print the error message NO
PHRASE LENGTH and stop.
ex. in a case where no arguments are being passed through the command line print
NO PHRASE LENGTH and stop.
You must detect the case where the argument specified for N is not an integer. In that case, print the
error message INVALID PHRASE LENGTH and stop, also if the integer is negative
Print NO MODE if a second argument is missing
so for xxx would print NO MODE because there is not a second argument.
Print INVALID MODE if the second argument is something other than all or top
You must detect the case where there are no file names specified. In that case, print the message NO
FILES GIVEN and stop.
If a file cannot be opened or read for any reason, print the error message BAD FILE FILENAME and
continue to the next file.
If there are no phrases at all, i.e. all empty files or no phrases long enough for the size given, then it
should print NO PHRASES
Note that it is also possible that ALL of the phrases in the input occur with the same frequency. In that
case, there is no phrase that appears more often than any other. In that case, the output should be ALL PHRASES EQUALLY FREQUENT
Write a program that will print out the followiing error cases for the situations listed above , the command arguments that are to be passed are in bold, but only the errors that have to do with command line arguments beinf passed.
youre welcome to try to for the files errors, it would be using code similary to this;
ifstream infile; infile.open(arg[v]);
using files from a file stream.
All of the error cases other than ALL PHRASES EQUALLY FREQUENT, including opening files, but NO file processing (i.e. just open and close the file to see if its there - no reading, no parsing, no counting, no printing)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
