C++  Need help with the functions  While testing I am not getting the count for the vowles and consontants.  Please jelp and test each option.  Write a function that accepts a C-string as its argument. The function should count the number of vowels appearing in the string and return that number. Write another function that accepts a C-string as its argument. This function should count the number of consonants appearing in the string and return that number. Demonstrate the two functions in a program that performs the following steps: 1. The user is asked to enter a string. 2. The program displays the following menu:   A) Count the number of vowels in the string   B) Count the number of consonants in the string   C) Count both the vowels and consonants in the string   D) Enter another string   E) Exit the program 3. The program performs the operation selected by the user and repeats until the user selects E, to exit the program.   // Sharissa Sullivan  //Febuary 2 2023 // Chapter 10 Vowels and Consonants  #include // headers for defining a string  and c string functions strlen #include #include   #include #include // to convert lower case letter to upper case  using namespace std; //Protype functions  int  countVowles(const char *); int countConst(const char *);      int main() {     //create the variables      char stringInput[100];          char outPut;     //Prompt the user to enter their name and display on screen      cout << " Enter your name with a max of 100 characters:\n ";     // Use a varaible to store the user input      //in >> stringInput;     // Use getline function to store the user input      cin.getline(stringInput, 101); // use do-while loop and print the following statments : use \n at the end of each sentence to go to the next line     do     {         cout << "\nEnter your choice \n";         cout << " A) Count the number of vowels in the string \n";         cout << " B) Count the number of consonants in the string \n";         cout << " C) Count both the vowels and consonants in the string\n";         cout << " D) Enter another string \n";         cout << " E) Exit the program\n";         cout << "    Please enter your choice\n";         cin >> (outPut);         // output is not equal to A,B,C,D,E  && = And  != not equal to          while (outPut != 'A' && outPut != 'B' && outPut != 'C' &&             outPut != 'D' && outPut != 'E');         {             cout << "Please enter a valid choice (A, B, C, D or E)!\n";             cin >> outPut;         }         switch (outPut)         {         case 'A':             cout << "There are" << countVowles(stringInput);             cout << "vowles in the string.\n";             break;         case 'B':             cout << "There are" << countConst(stringInput);             cout << " consonants in the string.\n";             break;         case 'C': // use strlen to return to the numbers of vowles and constants              cout << "There are " << strlen(stringInput);              cout << " vowels and constants in the string.\n";             break;         case 'D':             cout << "Enter your mother's name:";             cin.ignore();             cin.getline(stringInput, 101);             break;         case 'E':             break;         }     } while (outPut != 'E');         return 0;          } // Create count vowels function and return the number  int  countVowles(const char *pointer ) { //create variable      int vowels = 0;  //Use a while condition  while (*pointer != '\0') { // toupper retuns an upper case letter      if (toupper(*pointer) == 'A' || toupper(*pointer) == 'E' ||         toupper(*pointer) == 'I' || toupper(*pointer) == 'O' ||         toupper(*pointer) == 'U' || toupper(*pointer) == 'Y')         vowels++;         pointer++; }      return vowels++; } int countConst (const char *pointer) { //create a variable          int cCounter = 0;     while (*pointer != '\0') {         if (toupper(*pointer) != 'A' || toupper(*pointer) != 'E' ||             toupper(*pointer) != 'I' || toupper(*pointer) != 'O' ||             toupper(*pointer) != 'U' || toupper(*pointer) != 'Y' &&             isalpha(*pointer)             )             cCounter++;             pointer++;     }     return cCounter; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 

 

C++  Need help with the functions 

While testing I am not getting the count for the vowles and consontants. 

Please jelp and test each option. 

Write a function that accepts a C-string as its argument. The function should count the number of vowels appearing in the string and return that number.

Write another function that accepts a C-string as its argument. This function should count the number of consonants appearing in the string and return that number.
Demonstrate the two functions in a program that performs the following steps:
1. The user is asked to enter a string.
2. The program displays the following menu:
  A) Count the number of vowels in the string
  B) Count the number of consonants in the string
  C) Count both the vowels and consonants in the string
  D) Enter another string
  E) Exit the program
3. The program performs the operation selected by the user and repeats until the user selects E, to exit the program.

 

// Sharissa Sullivan 
//Febuary 2 2023
// Chapter 10 Vowels and Consonants 

#include <iostream>
// headers for defining a string  and c string functions strlen
#include <iostream>
#include <string> 
#include <cstring>
#include <cctype> // to convert lower case letter to upper case 
using namespace std;
//Protype functions 
int  countVowles(const char *);
int countConst(const char *);
    
int main() {
    //create the variables 
    char stringInput[100];
    
    char outPut;
    //Prompt the user to enter their name and display on screen 
    cout << " Enter your name with a max of 100 characters:\n ";
    // Use a varaible to store the user input 
    //in >> stringInput;
    // Use getline function to store the user input 
    cin.getline(stringInput, 101);
// use do-while loop and print the following statments : use \n at the end of each sentence to go to the next line
    do
    {
        cout << "\nEnter your choice \n";
        cout << " A) Count the number of vowels in the string \n";
        cout << " B) Count the number of consonants in the string \n";
        cout << " C) Count both the vowels and consonants in the string\n";
        cout << " D) Enter another string \n";
        cout << " E) Exit the program\n";
        cout << "    Please enter your choice\n";
        cin >> (outPut);
        // output is not equal to A,B,C,D,E  && = And  != not equal to 
        while (outPut != 'A' && outPut != 'B' && outPut != 'C' &&
            outPut != 'D' && outPut != 'E');
        {
            cout << "Please enter a valid choice (A, B, C, D or E)!\n";
            cin >> outPut;
        }

        switch (outPut)
        {
        case 'A':
            cout << "There are" << countVowles(stringInput);
            cout << "vowles in the string.\n";
            break;
        case 'B':
            cout << "There are" << countConst(stringInput);
            cout << " consonants in the string.\n";
            break;
        case 'C': // use strlen to return to the numbers of vowles and constants 
            cout << "There are " << strlen(stringInput); 
            cout << " vowels and constants in the string.\n";
            break;
        case 'D':
            cout << "Enter your mother's name:";
            cin.ignore();
            cin.getline(stringInput, 101);
            break;
        case 'E':
            break;
        }
    } while (outPut != 'E');
        return 0;
        
}
// Create count vowels function and return the number 

int  countVowles(const char *pointer ) {
//create variable 
    int vowels = 0; 
//Use a while condition 
while (*pointer != '\0') {
// toupper retuns an upper case letter 
    if (toupper(*pointer) == 'A' || toupper(*pointer) == 'E' ||
        toupper(*pointer) == 'I' || toupper(*pointer) == 'O' ||
        toupper(*pointer) == 'U' || toupper(*pointer) == 'Y')
        vowels++;
        pointer++;
}
     return vowels++;

}

int countConst (const char *pointer) {
//create a variable     
    int cCounter = 0;
    while (*pointer != '\0') {
        if (toupper(*pointer) != 'A' || toupper(*pointer) != 'E' ||
            toupper(*pointer) != 'I' || toupper(*pointer) != 'O' ||
            toupper(*pointer) != 'U' || toupper(*pointer) != 'Y' &&
            isalpha(*pointer)
            )
            cCounter++;
            pointer++;
    }
    return cCounter;

}

RT
TION
OW-UP
-TIONS
Output
Enter a string with a maximum of 100 characters:
Hellooworld
Enter your choice:
A) Count the number of vowels in the string
B) Count the number of consonants in the string
C)
Count both the vowels and consonants in the string
D) Enter another string
E) Exit the program
Please enter choice:
A
There are 4 vowels in the string!
Enter your choice:
A) Count the number of vowels in the string
B) Count the number of consonants in the string
c) Count both the vowels and consonants in the string
D) Enter another string
E) Exit the program
Please enter choice:
B
There are 7 cons
Write a function that accepts a C-stri
onsonants in the string!
Enter your choice:
A) Count the number of vowels in the string
B) Count the number of consonants in the string
C) Count both the vowels and consonants in the string
D) Enter another string
E) Exit the program
Please enter choice:
с
There are 11 vowels and consonants in the string!
Enter your choice:
A) Count the number of vowels in the string
B) Count the number of consonants in the string
c) Count both the vowels and consonants in the string
D) Enter another string
E) Exit the program
Transcribed Image Text:RT TION OW-UP -TIONS Output Enter a string with a maximum of 100 characters: Hellooworld Enter your choice: A) Count the number of vowels in the string B) Count the number of consonants in the string C) Count both the vowels and consonants in the string D) Enter another string E) Exit the program Please enter choice: A There are 4 vowels in the string! Enter your choice: A) Count the number of vowels in the string B) Count the number of consonants in the string c) Count both the vowels and consonants in the string D) Enter another string E) Exit the program Please enter choice: B There are 7 cons Write a function that accepts a C-stri onsonants in the string! Enter your choice: A) Count the number of vowels in the string B) Count the number of consonants in the string C) Count both the vowels and consonants in the string D) Enter another string E) Exit the program Please enter choice: с There are 11 vowels and consonants in the string! Enter your choice: A) Count the number of vowels in the string B) Count the number of consonants in the string c) Count both the vowels and consonants in the string D) Enter another string E) Exit the program
Expert Solution
Step 1

Please refer to the following steps for the complete solution to the problem above.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education