aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--ee1301/wk3/hw3_directory/strap012_HW3B.cpp2
-rw-r--r--ee1301/wk3/hw3_directory/strap012_HW3C.cpp17
2 files changed, 9 insertions, 10 deletions
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