#include #include #include #include using namespace std; int main() { vector alphabet; cout << "Please input a sentence (please input lowercase)"; string sentence; getline(cin, sentence); //cin is limiting, replaced with getline. if (!cin) { cout << "That isn't a sentence.\n"; return EXIT_FAILURE; } for (int i {0}; i < sentence.size(); ++i) { char c = sentence[i]; if (c >= 'a' && c <= 'z') { alphabet.push_back(c); } } vector::size_type n {alphabet.size()}; int mostused {0}; char freqletter {'a'}; for (int i {0}; i < n; ++i) { int count {0}; char letter = alphabet[i]; for (int k {0}; k < n; ++k){ if (alphabet[k] == letter) { ++count; } } if (count > mostused) { mostused = count; freqletter = letter; } } cout << "Your sentence has the letter, " << freqletter << ", used" << " " << mostused; if (mostused == 1) { cout << " time.\n"; } else { cout << " times.\n"; } return EXIT_SUCCESS; }