Write a main() routine that first prompts the user for their full name. Read this all into a c-string (we can assume that their name will be 79 characters long or less), and welcome them as seen in the sample runs.Then, prompt them 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 this data in one char at a time, and analyze 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. The idea is to read in a letter, search your letter array for that letter, and increase the appropriate frequency for that letter in your frequency array.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.HINTS:
– When reading in the user’s name at the beginning, remember, their name may contain spaces… you may need to use getline to help here.
– Read in and analyze one letter at a time (read each char into a character variable using >> , 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 the extraction operator >> skips over whitespace too, so this helps by ignoring spaces, newlines, tabs, etc, as well.
– You may assume the user will enter at least one valid lowercase letter before entering a ? to quit.Sample Run 1:(user input underlined)What’s your name? Melina Myers
Welcome, Melina Myers!
Enter as many words or letters as you’d like, and I’ll count them up!
When you’re done, enter a ? character.fuzzy wuzzy was a bear
?Thanks for using the letter counter Melina Myers!Here’s your results:Letter Frequency
a 5
b 1
d 1
e 1
f 2
h 2
i 1
n 1
o 1
r 2
s 1
u 4
w 3
y 4
z 8The letter(s) appearing most were:
with 8 occurrences

New Download