This is a C++ (COP3014) Assignment – Please go by the requirements if possible =)
Can’t just use 27 if/else or 27 case statements!
Write a main() routine that prompts the user to enter lowercase letters at their will that will be analyzed by your program. The user can enter multiple letters per line (words, random letters, whatever), or a single letter per line as the program runs. The program should read in and analyze one letter at a time (one char at a time). ‘Analyze’ them by keeping track of the frequencies of the letters entered by the user by adding one to each letter’s frequency count. Obviously, begin the frequencies of all letters at 0. The user can stop the letter analysis by entering a ?. User entries that do not begin with a letter a-z should not count towards any letter’s frequency. When the user enters a ? to stop analyzing letters, call your getResults() function, and based on its return value, print out the most common letter(s) the user entered (see sample runs)
REQUIREMENT for main():
Use two arrays in your program, declared at the beginning of main() — one that stores the literal char values of each character of the alphabet, a-z , and the other that keeps track of letter frequencies (type int). These arrays should be used one-to-one (in parallel), meaning that the first element (index 0) in the frequency array should correspond to frequency for ‘a’, the second element (index 1) in the frequency array should correspond to frequency for ‘b’, etc.
When the user is done entering letters, call a function you write called getResults() that takes in the two arrays as parameters, and returns the frequency value of the most common letter(s) as an int (note that more than one letter may have the highest frequency count). Based on how this function uses your arrays, think about if the arrays should be passed to the functions as const or not. This function should print out a table of the frequencies of each letter. If a letter was never entered by the user (aka, the frequency of a letter is 0), do not print out an entry for that letter. Output should match mine below exactly.
– Analyze one letter at a time (read in using cin, and increase frequency for that letter).
– Read up on passing arrays into functions — we’ll cover this in class, too.
– Utilize loops where necessary.
– The user is free to enter special characters, uppercase letters, or numbers. Just do not count these towards any letter frequencies. Remember that cin >> skips over whitespace too, so this helps by ignore spaces, newlines, tabs, etc, as well.
– You may assume the user will enter at least one valid lowercase letter before entering a ? to quit.
ANY HELP APPRECIATED – THANKS :]