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_HW3B.cpp | 2 +- ee1301/wk3/hw3_directory/strap012_HW3C.cpp | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'ee1301') diff --git a/ee1301/wk3/hw3_directory/strap012_HW3B.cpp b/ee1301/wk3/hw3_directory/strap012_HW3B.cpp index dac276d..4a80ae7 100644 --- a/ee1301/wk3/hw3_directory/strap012_HW3B.cpp +++ b/ee1301/wk3/hw3_directory/strap012_HW3B.cpp @@ -58,7 +58,7 @@ int charTest (char character) { if (character>= 'A' && character<='Z') { return 3; } else { - return 0; + return 0; } } } 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