Hello please help me with this C programming challenge Proce

Hello, please help me with this C++ programming challenge.

Processing Text

Program Objective

Write a program that asks the user to enter some text and then counts the number of vowels, consonants, uppercase letters, lowercase letters, punctuation characters, and words.

Program Specifications

You program must:

-Ask the user to enter some text consisting only of letters, spaces, and the following punctuation characters . , ; : ! ?

-The user will signal the end of the text by typing enter/return.

Use a string object to store the entered text (not a C-style string)

Determine how many of the characters in the text entered are:

• Vowels

• Consonants

• Uppercase

• Lowercase

• Punctuation (. , : ; ! ?)

Determine the number of words in the text

-For the purpose of this challenge, vowels are a, e, i, o, u (or A, E, I, O, U). All other letters (including y and Y) are consonants

-For the purpose of this challenge, a word is any group of one or more characters (letters and/or . , ; : ! ?) separated by one or more spaces from any other group of one or more characters.

Display the number of vowels, consonants, uppercase letters, lowercase letters, punctuation characters, and words.

*NOTE: The user may enter one or more spaces at the start and/or end of the text. Your code must be able to handle this scenario.

**NOTE: The starter code contains nine cout statements. You MUST use these nine cout statements exactly as they are given. Do NOT modify these statements. Do NOT change the order of these cout statements. Do NOT add additional cout statements.

Starter Code:


    cout << \"Enter some text. Letters and the following punctuation only please . , : ; ! ?\" << endl;
cout << \"Pressing enter/return will end the text.\" << endl;
  


cout << \"The number of vowels is: \" << voweltally << endl;
cout << \"The number of consonants is: \" << contally << endl;
cout << \"The number of uppercase letters is: \" << uppertally << endl;
cout << \"The number of lowercase letters is: \" << lowertally << endl;
cout << \"The number of punctuation characters is: \" << punctally << endl;
cout << \"The number of words is: \" << wordtally << endl;
cout << \"Exiting program ...\" << endl;

***NOTE: Make sure you test it with a variety of different texts.

The following are examples of correct execution of the program.

Enter some text. Letters and the following punctuation only please . , : ; ! ?

Pressing enter/return will end the text.

This is a test!

The number of vowels is: 4

The number of consonants is: 7

The number of uppercase letters is: 1

The number of lowercase letters is: 10

The number of punctuation characters is: 1

The number of words is: 4

Exiting program ...

OR

Enter some text. Letters and the following punctuation only please . , : ; ! ?

Pressing enter/return will end the text.

Another test.

The number of vowels is: 4

The number of consonants is: 7

The number of uppercase letters is: 1

The number of lowercase letters is: 10

The number of punctuation characters is: 1

The number of words is: 2

Exiting program ...

OR

Enter some text. Letters and the following punctuation only please . , : ; ! ?

Pressing enter/return will end the text.

Still another test !!!

The number of vowels is: 5

The number of consonants is: 11

The number of uppercase letters is: 1

The number of lowercase letters is: 15

The number of punctuation characters is: 3

The number of words is: 4

Exiting program ...

OR

Enter some text. Letters and the following punctuation only please . , : ; ! ?

Pressing enter/return will end the text.

This, however, is the LAST.

The number of vowels is: 7

The number of consonants is: 13

The number of uppercase letters is: 5

The number of lowercase letters is: 15

The number of punctuation characters is: 3

The number of words is: 5

Exiting program ...

Solution

#include <iostream>
using namespace std;

int main()
{
string line;
int vowels, consonants, punctuation, words=1,lower,upper;

vowels = consonants = punctuation = lower = upper = 0;

cout << \"Enter a line of string: \";
getline(cin, line);
// line = \"This, however, is the LAST.\";

for(int i = 0; i < line.length(); ++i)
{
if((line[i]>=\'a\'&& line[i]<=\'z\') )
  
{

++lower;
if(line[i]==\'a\' || line[i]==\'e\' || line[i]==\'i\' ||
line[i]==\'o\' || line[i]==\'u\' )
{
++vowels;
}
else
{
++consonants;
}
}   

else if((line[i]>=\'A\'&& line[i]<=\'Z\'))
  
{
++upper;
if(line[i]==\'A\' ||
line[i]==\'E\' || line[i]==\'I\' || line[i]==\'O\' ||
line[i]==\'U\')
{
++vowels;
}
else
{
++consonants;
}
  
}
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  

else if(line[i]==\'.\' || line[i]==\',\' || line[i]==\':\' || line[i]==\';\' ||line[i]==\'!\' || line[i]==\'?\')
{
++punctuation;
}
else if (line[i]==\' \')
{
++words;
}
  
  
}

cout << \"Vowels: \" << vowels << endl;
cout << \"Consonants: \" << consonants << endl;
cout << \"Uppercase: \" << upper << endl;
cout << \"Lowercase: \" << lower << endl;
cout << \"Punctuation characters: \" << punctuation << endl;
cout << \"Words : \" << words << endl;

return 0;
}

Hello, please help me with this C++ programming challenge. Processing Text Program Objective Write a program that asks the user to enter some text and then coun
Hello, please help me with this C++ programming challenge. Processing Text Program Objective Write a program that asks the user to enter some text and then coun
Hello, please help me with this C++ programming challenge. Processing Text Program Objective Write a program that asks the user to enter some text and then coun
Hello, please help me with this C++ programming challenge. Processing Text Program Objective Write a program that asks the user to enter some text and then coun

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site