From 850b130375fb626167c00aba6aeba16f751910c8 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Wed, 27 Feb 2019 12:25:43 -0600 Subject: Some final touches/editing --- ee1301/wk3/hw3_directory/strap012_HW3C.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'ee1301/wk3/hw3_directory/strap012_HW3C.cpp') diff --git a/ee1301/wk3/hw3_directory/strap012_HW3C.cpp b/ee1301/wk3/hw3_directory/strap012_HW3C.cpp index 61af587..54f9af5 100644 --- a/ee1301/wk3/hw3_directory/strap012_HW3C.cpp +++ b/ee1301/wk3/hw3_directory/strap012_HW3C.cpp @@ -16,8 +16,7 @@ using namespace std; void swapCase(char s); -int main() -{ +int main() { char character; do { //This loops until '@' is entered cout << "Please enter a character that is an ASCII letter in the range [A-Za-z]: "; @@ -37,16 +36,16 @@ int main() void swapCase(char s) { char New; cout << "You entered " << s; - if (s >= 'a' && s <= 'z') { - New= s - 32; - cout << ", I respond with " << New; - } else { + if ( (s >= 'a' && s <= 'z') || (s >= 'A' && s <= 'Z') ) { + cout << ", I respond with "; if (s >= 'A' && s <= 'Z') { - New = s + 32; - cout << ", I respond with " << New; + New = s + 32; //32 is the difference between capital and lowercase ASCII characters } else { + New= s - 32; + } + cout << New; + } else { cout << ", which is not a valid character."; } - } cout << endl; } \ No newline at end of file -- cgit v1.2.3