Question

In: Computer Science

C++, Need to create a code that will calculated the statistics for character input? This is...

C++, Need to create a code that will calculated the statistics for character input?

This is the prompt for the code. I truly understand nothing of what it's asking.

Ask the user for one character (terminated by a carriage return).Using flow control, classify the character into one of these categories:

1)           vowel

2)           consonant

3)           digit (0-9)

4)           other

Output the character input, its numeric decimal value, and the classification. Total up the number of each type of character entered. After the character is entered, ask the user if they want to continue (Y/N). When they enter N, you can stop prompting for more characters. Make sure to validate for Y or N data entry. Then display the total number of each type of characters entered.

Solutions

Expert Solution

Note : Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

#include <iostream>
#include<cmath>
#include<iomanip>
using namespace std;

bool isVowel(char ch);
int main()
{
int cntVowel=0,cntConsonant=0,cntDigit=0,cntOther=0;     
char ch,YorN;

while(true)
{
   cout<<"Enter a character :";
   cin>>ch;
   if(isVowel(ch))
   {
       cntVowel++;
       }
       else if((ch>='A' && ch<='Z') ||(ch>='a' && ch<='z') && !isVowel(ch))
       {
           cntConsonant++;
       }
       else if(isdigit(ch))
       {
           cntDigit++;
       }
       else
       {
           cntOther++;
       }
       cout<<"\nDo you Want to continue(Y/N):";
       while(true)
       {
           cin>>ch;
           if(ch=='y'||ch=='Y')
           {
           break;
           }
           else if(ch=='N' || ch=='n')
{
cout<<"Vowels :"<<cntVowel<<endl;
   cout<<"Consonants :"<<cntConsonant<<endl;
   cout<<"Digits :"<<cntDigit<<endl;
   cout<<"Others :"<<cntOther<<endl;
           exit(0);
}
else
{
   cout<<"Invalid choice.Re-Enter :";
           }
       }

   }
  
  
   return 0;
}
bool isVowel(char ch)
{
   if(ch=='a' || ch=='A'|| ch=='e' ||
           ch=='E' ||ch=='i' || ch=='I'||
           ch=='o' || ch=='O'|| ch=='u' || ch=='U')
           {
           return true;   
           }
           else
           {
              return false;
           }
  
}

____________________________

// Output:


_______________Could you plz rate me well.Thank You


Related Solutions

I need to create a code in C++ that first has a menu animation of game...
I need to create a code in C++ that first has a menu animation of game Pacman, a score label in the map, and a bar that have the lives of pacman in the map.
Write a basic C++ program with function, whose input is a character and a string, and...
Write a basic C++ program with function, whose input is a character and a string, and whose output indicates the number of times the character appears in the string. Ex: If the input is: n Monday the output is: 1 Ex: If the input is: z Today is Monday the output is: 0 Ex: If the input is: n It's a sunny day the output is: 2 Case matters. n is different than N. Ex: If the input is: n...
Statistics are often calculated with varying amounts of input data. Write a program that takes any...
Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative integers as input and outputs the average and max. A negative integer ends the input and is not included in the statistics. Ex: When the input is 15 20 0 5 -1, the output is: 10 20 You can assume that at least one non-negative integer is input. Can this be written in CORAL please!!
Statistics are often calculated with varying amounts of input data. Write a program that takes any...
Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative integers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics.
C++ Create the code Read  numbers from stdin and print their sum to stdout. Input Format One...
C++ Create the code Read  numbers from stdin and print their sum to stdout. Input Format One line that contains  space-separated integers:a , b, c and . Constraints 1≤ a,b,c ≤1000 Output Format Print the sum of the three numbers on a single line. Sample Input 1 2 7 Sample Output 10 Explanation The sum of the three numbers is 1+2+7=10
In objective-C Task: Write a program whose input is a character and a string, and whose...
In objective-C Task: Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in the string. The output should include the input character and use the plural form, n's, if the number of times the characters appears is not exactly 1.You may assume that the string does not contain spaces and will always contain less than 50 characters. Ex: If the input is: n Monday the output is:...
Use C language Write a program that reads in a series of lines of input character...
Use C language Write a program that reads in a series of lines of input character by character (using getchar()). The first line of the input contains an integer which specifies the number of remaining lines of input, each of which contains a floating point number. The integer value on the first line can be read with scanf(), but all of the following lines can only be read with getchar(). Each line after the first contains a single floating point...
How do I write a C# and a C++ code for creating a character array containing...
How do I write a C# and a C++ code for creating a character array containing the characters 'p', 'i', 'n','e','P','I','N','E' only and then using these lower and capital case letter character generate all possible combinations like PInE or PinE or PIne or PINE or piNE etc. and only in this order so if this order is created eg. NeIP or EnPi or NeIP or IPnE and on. You can generate all the combinations randomly by creating the word pine...
Please write code in c++. Use iostream (and any string library if you need it). Create...
Please write code in c++. Use iostream (and any string library if you need it). Create s structure plane : First line contains n(0 < n < 1001). Then n lines inputed in given format:   First - ID[int type]   Second - FromLocation[char*]   Third - ToLocation[char*]   Fourth - DepartureTime[char*] Output: Sorted list of planes should be in UPPER CASE. Example of input:(it's just one of an examples, you need to write code generally) 10 40 Shuch Satp 05:47 89 Kyzy Taldy  07:00...
I need this code in C++ form using visual studios please: Create a class that simulates...
I need this code in C++ form using visual studios please: Create a class that simulates an alarm clock. In this class you should: •       Store time in hours, minutes, and seconds. Note if time is AM or PM. (Hint: You should have separate private members for the alarm and the clock. Do not forget to have a character variable representing AM or PM.) •       Initialize the clock to a specified time. •       Allow the clock to increment to the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT