I need help with homework.

For the following problem turn in both an algorithm and a program along with output.

1) Write a program where the user has to enter any single character from the keyboard. The program will then display the entered character along with its corresponding ASCII value. The program will also keep track or record of each entered character to determine if the entered character is an upper case letter, a lower case letter, a number 0 to 9, or some other character. The program will also display the next two characters immediately following the entered one after each entered character. This should continual to loop until the user enters the ‘#’ character to quit. After the loop is done then the program should display the number of upper case, lower case, numbers , and other characters entered. Use “cin >> “ in program, don’t worry about counting white space characters.
What does "The program will also display the next two characters immediately following the entered one after each entered character." means? Do you have an example?

You will need to include <cctype> header ( http://en.cppreference.com/w/cpp/header/cctype ) and use islower(), isupper(), etc. functions to determine character category

quick code mockup:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <cctype>

int main()
{
    unsigned lower = 0,
             upper = 0,
             digit = 0,
             other = 0;
    char inp = '#';
    std::cin >> inp;
    while(inp != '#') {
        std::cout << static_cast<int>(inp) <<'\n';
             if (std::isupper(inp)) ++upper;
        else if (std::islower(inp)) ++lower;
        else if (std::isdigit(inp)) ++digit;
        else                        ++other;
        std::cin >> inp;
    }
    std::cout << "\nUppercase letters: " << upper <<
                 "\nLowercase letters: " << lower <<
                 "\n...";
}
Topic archived. No new replies allowed.