Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Functionality. This file should contain the function definitions for the following functions: countLetters Input Parameters: a single string Returned Output: integer number of letters in
Functionality. This file should contain the function definitions for the following functions: countLetters Input Parameters: a single string Returned Output: integer number of letters in that word Functionality: This function should accept as a parameter a single string which stores one word. It should iterate over the string and count how many characters are letters (not punctuation). countUpperCaseLetters Input Parameters: a single string Returned Output: integer number of upper-case letters in the input word Functionality. This function should accept as a parameter a single string which stores one word. It should iterate over the string and return the number of characters that are upper-case letters. countLettersInRangel Input Parameters: a single string, a character as the lower bound, and a character as the upper bound Returned Output: the number of characters that are within the range between the lower and upper bound characters, inclusive Functionality. This function should accept as a parameter a single string which stores one word. It should iterate over the string and count how many characters fall inclusively within the character range. File driver.cpp maino Functionality. The main function should check for the correct number of command line arguments and display an error message including the file name) if necessary. It should then call the appropriate functions defined below) to calculate metrics for the input file. Finally, it should print the results of the analysis. Call getWords to open the file and retrieve the words. If it returns an error code of -1, print the appropriate error message (see above) and exit the program. If it succeeds, call the functions required to analyze the words in the array. Do not print inside these functions. Output to the user should only occur in the main. getWords Input Parameters: integer size of string array, array of strings, string filename Returned Output: integer number of words stored Functionality: This function should accept a filename, an array of strings for storing each of the words, and a size parameter for the array. It should attempt to open the input file for reading. If it cannot open the input file for reading, it should return - 1. If it can open the input file for reading, it should get each of the words from the file and store them into the array of strings that was passed in. Finally, it should return the number of words it successfully pulled from the file. findLongest Word Input Parameters: integer size, array of strings Returned Output: string Functionality: This function should accept an array of strings containing all the words (one word per string). The function should return the longest word in the array. File word_analyzer.h This file should contain the function prototypes for the following functions: int countLetters(string word); int countLettersInRange(string word, char lower, char upper); int countUpperCaseLetters(string word); File word_analyzer.cpp Programming Problem Write a program for analyzing text loaded from a file. The name of the text file should be provided as a command line argument. If a filename is not provided, an error message should be displayed to the user. If the file cannot be opened for reading, an error message should be displayed to the user. Assuming that the file is successfully opened the following metrics must be determined: The total number of letters in the file. Numbers, spaces, and punctuation should be excluded. Example: "abd'd" contains 4 letters, not 5 (ignoring the " characters of course...) The longest word in the file The total number of lowercase letters between 'a' and 'f (inclusive) in the file. The total number of upper case letters in the file Here is an example of how the program could function using the following poem.txt file as input: Haikus are Easy But sometimes they don't make sense. Refrigerator. Program Output > ./text_analyzer Correct usage: ./text_analyzer filename > ./text_analyzer badfile.txt The file badfile.txt could not be opened > ./text_analyzer poem.txt There are 54 letters in your file. There are 4 upper case letters in your file. There are 16 letters between 'a' and 'f'. The longest word in this file is "Refrigerator
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started