aboutsummaryrefslogtreecommitdiffstats
path: root/ee1301/wk3/hw3_directory/strap012_HW3B.cpp
blob: 8a23e240f48b030bd855b06a34c706f84b9d7b05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
27 Feb 2019
Matthew Strapp
5449340
EE1301
Spring 2019
Homework 3B
Character Detection
*/

#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <iomanip>
using namespace std;

int main () {
    char character;
    bool isNotAlphaNumeric=false;
    while (!isNotAlphaNumeric) {
    cout << "Enter a single digit or an alphabetic character: ";
    cin >> character;
    cout << "You entered " << character;
    if (character >= '0' && character <= '9')
    {
        cout <<  ", which is a number." << endl;
    } else {
        if (character>='a' && character<='z') {
            cout << ", which is a lower case letter." << endl;
        } else {
            if (character>= 'A' && character<='Z') {
                cout << ", which is an upper case letter." << endl;
            } else {
                isNotAlphaNumeric=true;
                cout << ", which is not a letter or a number." << endl;
            }
        }
        }
    }
}