From 1890f33d93f6643c4491b0c6f10ff3ae7ac7bc47 Mon Sep 17 00:00:00 2001 From: RossTheRoss Date: Sun, 24 Feb 2019 11:56:45 -0600 Subject: Finish 3C --- ee1301/wk3/hw3_directory/strap012_HW3C.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'ee1301') diff --git a/ee1301/wk3/hw3_directory/strap012_HW3C.cpp b/ee1301/wk3/hw3_directory/strap012_HW3C.cpp index 59b1347..ac7bc1c 100644 --- a/ee1301/wk3/hw3_directory/strap012_HW3C.cpp +++ b/ee1301/wk3/hw3_directory/strap012_HW3C.cpp @@ -4,10 +4,36 @@ #include using namespace std; char 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') + { + New = s + 32; + cout << ", I respond with " << New; + } + else + { + cout << ", which is not a valid character"; + } + } + cout << "." << endl; } int main() { - + char character; + do { + cout << "Please enter a character that is an ASCII letter in the range [A-Za-z]: "; + cin >> character; + if (character!='@') { + swapCase(character); + } + } while (character!='@'); } \ No newline at end of file -- cgit v1.2.3