Write a program that counts number of words in a sentence and displays the average number of letters in each word. Your program should ask the user to type a sentence (or sentences) that are 80 characters or less. If the sentence is longer than 80 characters, truncate it and notify the user of your action.
Your program should call:
• A function that accepts a string class object as its argument and returns the number of words contained in the string. For example, if the string argument is “Four score and seven years ago” the function should return the number 6.
• A function that accepts a string class object as its argument and returns the number of punctuation characters (period, comma, exclamation, etc.) in the sentence(s).
• A function that accepts a string class object as its argument and returns the average number of letters in each word.
Your program should present the user with the following menu:
A. Count number of words in the sentence
B. Count number of punctuations in the sentence
C. Compute the average number of letters in each word
D. Enter another sentence
E. Exit
The program should exit when the user selects “E” to exit the program. Pass data to your functions by value, by reference, anduse static variables if necessary.

#include <iostream> 
#include <iomanip> 
#include <cctype> 
#include <cstring> 
using namespace std; 

const int MAX = 80;
int countWords(const string&);
int countPunc(const string&);

int main(int argc, char *argv[]) { 
string input, choice;
char ch;

cout << "Enter a string: ";
getline(cin,input);

do {
cout << " MENU" << endl;
cout << "A> Count the Number of words in the sentence." << endl;
cout << "B> Count the number of punctuations in the sentence." << endl;
cout << "C> Compute average." << endl;
cout << "D> Enter another string." << endl;
cout << "E> Exit this program." << endl; 
cout << "Enter A, B, C, D, OR E." << endl;
getline(cin,choice);

switch (ch = tolower(choice[0])) {
case 'a': 
cout << "The string has " << countWords(input) << " vowels." << endl;
break;
case 'b': 
cout << "The string has " << countPunc(input) << " consonants." << endl;
break;
case 'c': 
cout << "The average " << countAvg(input) << " yeah " << endl;
break;
case 'd': 
cout
This article has been dead for over six months. Start a new discussion instead.