//program to count occurances of a letter in a line of text #include #include int main() { try{ char c(0); //int count(0); int lettercount(0); std::cout << "Please type in a line of text.\n"; do { c = std::cin.get(); if(not std::cin) throw std::exception(); if(c == '\n') break; if(c == 'a' or c == 'A') { ++lettercount; } } while(true); std::cout << "You typed in " << lettercount << " a's \n"; } catch(...) { std::cerr << "***An exception was thrown.***\n"; } }