A word is defined as a sequence of one or more non-whitespace characters separated by whitespace. A word is defined as a name if it starts by a letter or an underscore ‘_’, and followed by zero or...

1 answer below »

A word is defined as a sequence of one or more non-whitespace characters separated by whitespace. A word is defined as a name if it starts by a letter or an underscore ‘_’, and followed by zero or more letters, digits, underscores ‘_’, or ‘@’ characters. For example, value, val@l9, num234ten, _num_45 are valid names, but 9val, and &num are not. A word is defined as an integer if it starts by a digit or an optional sign (i.e., ‘-‘ or ‘+’) and followed by zero or more digits. For example, 2345, -345, +543 are integer words, while 44.75, and 4today45 are not. Note that a line having only whitespace characters is a blank line as well.


The program should accept one or more command line arguments for a file name and input flags. The notations for the command line arguments are specified as follows:



  • The first argument must be a file name.

  • -all (optional): If it is present, the program prints the number of integer and name words in the file.

  • -ints (optional): If it is present, the program prints the number of integer words only in the file.

  • -names (optional): If it is present, the program prints the number of name words only in the file.


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. In case the command line does not include any of the optional flags, the program should print out the total number of lines, the number of non-blank lines, and the total number of words only. If an optional flag argument is not recognized, the program should print out the message “UNRECOGNIZED FLAG”.

Answered Same DaySep 26, 2022

Answer To: A word is defined as a sequence of one or more non-whitespace characters separated by whitespace. A...

Uhanya answered on Sep 26 2022
51 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here