Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ONLY C++ PLEASE!! i already saw there are a few other answers in chegg. please dont just copy and paste it. they check plagiarism, so

ONLY C++ PLEASE!! i already saw there are a few other answers in chegg. please dont just copy and paste it. they check plagiarism, so please also show me the output with an original code. thanks!
image text in transcribed
image text in transcribed
COSC1437 Lab \#2 Letter Count Write a C++ program that reads text from a file called letter_count.txt. The program determines which alphabetic character occurs most frequently in the text and which alphabetic character appears least frequently in the text. Your program must: 1. Read each line of the file, no matter how many lines there are. 2. Display an appropriate message if the letter_count.txt file is not found. 3. Count both lower case and upper case variants as the same character. In the text, "Now is the time for all good men to come to the aid of their country", the letter T occurs 7 times. 4. Ignore non-alphabetic characters, such as space, period, apostrophe, etc. 5. Display the most common letter in the file and its number of occurrences. 6. Display the least common letter in the file and its number of occurrences. 7. If there is a tie for the most (or least) common letter, the program only needs to display one of the letters which was most (or least) common. 8. For this program, only the C++ string class may be used. C-strings or C-string functions may not be used for this assignment. 9. Your program must include at least one function that uses one or more reference variables as parameters. 10. No global variables may be used for this program. Hints: - Section 5.11 has examples of reading from a file. Program 5-22 illustrates reading until the End of File is found. The difference is that your program will read strings instead of ints. Program 12-8 illustrates how to use getline with C++ string objects in a loop. - The toupper function can be used to convert lowercase letters to uppercase. - The isalpha function can be used to determine if the character is an alphabetic character. - You can use a 26 element integer array to keep track of the letter counts by subtracting 'A' from the Ascii value of the character. Like, letterCount[letter 'A'] = letterCount[letter - 'A'] + I; Once you have tested the program, upload the .cpp file. Be sure to put your name in your program. A sample file is attached to this assignment. The correct output for this file is below. Note that I will test your programs with a different text file. The most common letter is E with 147 occurences. The least common letter is J with 0 occurences. Extra Credit ( 10 Points) Enhance the program so if there is a tie for the most (or least or both) common letter, the program displays all of the letters that are tied. So for this input, the output would look like - The most common letter is E with 147 occurences. The least common letters are J,X with 0 occurences

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

4-6 Is there a digital divide? If so, why does it matter?

Answered: 1 week ago