// counts the number of letters in input line #include #include int main() { try{ char c(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 >= 65 && c <= 90) // is uppercase { ++lettercount; } if(c >= 97 && c <= 122) // lowercase { ++lettercount; } } while(true); std::cout << "You typed in " << lettercount << " letters\n"; } catch(...) { std::cerr << "***An exception was thrown.***\n"; } }