Question
C++ Write a program that inputs a sequence of letters and keeps track of the longest consecutive sequence of the same letter within those inputted.
C++
Write a program that inputs a sequence of letters and keeps track of the longest consecutive sequence of the same letter within those inputted. The program should stop when the character . is inputted. Upper and lower case letters (for example, a and A ) should be considered equal.
Hints:
Checking to see if a character of input is a letter will involve two parts: Checking to see if a character is a lower-case letter can be done with the following (userInput is a character):
if ( userInput >= a && userInput <= z )...
Checking for upper-case (capital) letters is similar.
Some things that your program will need to keep track of (after inputting each letter, each of these may need to be updated):
- the last letter seen
- the number of the last letter which have recently been seen in a row
- the letter of the longest sequence seen so far
- how many letters were in the longest sequence seen so far
The executable program Gold06.exe demonstrates what your program should do. Note that it does not need to pause at the end since the user has already indicated its time to stop.
https://www.dropbox.com/sh/5ljmmkdf2419cgb/AAA75jn7-emWNhxBIs7Qh3gna/CMPR%20120%20Files?dl=0&preview=Gold06.exe
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