Here's my code:
#include <fstream>
#include <iostream>
#include <iomanip>
#include <cctype>

using namespace std;

enum Features { UPPER, LOWER, DIGIT, IGNORE, EOW, EOS, HYPHEN };

struct Counters
{
	int uppercase;
	int lowercase;
	int digit;
	int word;
	int sentence;
	int ignore;
};


void OpenFile(ifstream&);


Features Decode(char character);


void IncrementCounters(Counters& counters, char character, ifstream& inFile);

void PrintTable(Counters counters);

void InitializeCounters(Counters& counters);


int main()
{

	ifstream text;
	Counters counters;
	OpenFile(text);
	if (!text)
	{
		cout << "Files did not open successfully." << endl;
		return 1;
	}

	InitializeCounters(counters);
	char character;

	text.get(character);
	do
	{
		IncrementCounters(counters, character, text);
		text.get(character);
	} while (text);

	PrintTable(counters);
	text.close();
	return 0;
}



Features Decode(char character)

{
	if (isupper(character))
		return UPPER;
	else if (islower(character))
		return LOWER;
	else if (isdigit(character))
		return DIGIT;
	else
		switch (character)
		{
		case '.':
		case '?':
		case '!':  return EOS;

		case ' ':
		case ',':
		case ';':
		case ':':
		case '\n':  return EOW;

		case '-': return HYPHEN;
		}
	return IGNORE;
}



void OpenFile(ifstream& text)
{
	string inFileName;
	cout << "Enter the name of the file to be processed" << endl;
	cin >> inFileName;
	text.open(inFileName.c_str());
	cout << "Analysis of characters on input file " << inFileName
		<< endl << endl;
}




void PrintTable(Counters counters)


{
	int totalAlphaNum;
	totalAlphaNum = counters.uppercase + counters.lowercase
		+ counters.digit;


	cout << "Total number of alphanumeric characters: "
		<< totalAlphaNum << endl;
	cout << "Number of uppercase letters: " << counters.uppercase
		<< endl;
	cout << "Number of lowercase letters: " << counters.lowercase
		<< endl;
	cout << "Number of digits: " << counters.digit << endl;
	cout << "Number of characters ignored: " << counters.ignore
		<< endl;


	counters.word = counters.word + counters.sentence;


	cout << "Number of Words: " << counters.word << endl;
	cout << "Number of sentences: " << counters.sentence << endl;
	cout << "Average word length: " << fixed << setprecision(2)
		<< static_cast<float>(totalAlphaNum) / counters.word << endl;
	cout << "Average sentence length: " << fixed << setprecision(2)
		<< static_cast<float>(counters.word) / counters.sentence << endl;

}



void IncrementCounters(Counters& counters, char character, ifstream& inFile)


{
	static bool endOfWord = false;

	switch (Decode(character))
	{
	case UPPER: counters.uppercase++;
		endOfWord = false;
		break;
	case LOWER: counters.lowercase++;
		endOfWord = false;
		break;
	case DIGIT: counters.digit++;
		endOfWord = false;
		break;
	case EOW: if (!endOfWord)
	{
		counters.word++;
		endOfWord = true;
	}
			break;
	case EOS: counters.sentence++;
		endOfWord = true;
		break;
	case HYPHEN:
		counters.ignore++;
		if (inFile.peek() == ' ' || inFile.peek() == '\n')
		{
			endOfWord = false;
			if (inFile.peek() == ' ' || inFile.peek() == ',' || inFile.peek() == ';' || inFile.peek() == ':' || inFile.peek() == '\n')
			{
				endOfWord = true;
			}
		}
		else if (isupper(inFile.peek()) || islower(inFile.peek()))
		{
			counters.word++;
			endOfWord = true;
		}
		break;
	case IGNORE: counters.ignore++;
		break;
	}
}



void InitializeCounters(Counters& counters)
{
	counters.uppercase = 0;
	counters.lowercase = 0;
	counters.digit = 0;
	counters.word = 0;
	counters.sentence = 0;
	counters.ignore = 0;
}