Question
C++, Visual Studio Write a program which: Asks the user to enter any sequence of characters The program should display all the lower-case vowels that
C++, Visual Studio
Write a program which:
Asks the user to enter any sequence of characters
The program should display all the lower-case vowels that are present and the number of times each vowel occurs
The program should display all the upper-case vowels that are present and the number of times each vowel occurs
The program should display the upper-case vowel which appears most frequently in the user input AND the number of times it appeared.
The program should display the lower-case vowel which appears most frequently in the user input AND the number of times it appeared.
The user must be asked if he/she wants to continue entering values or quit.
You must demonstrate effective use of the new and delete operators.
Remember to comment your code
Use meaningful or mnemonic variable names
You must use a pointer to a variable of type char to store the user input, and you MUST allocate the EXACT amount of memory to store all the characters entered by the user. For example:
If the user types Awq, then you need to use the new operator to allocate dynamic memory for a pointer to a char of size 3: UserInputCharArray = new char[3];
If the user types 300 letters, then you need to use the new operator to allocate memory for a pointer to a char of size 300: UserInputCharArray = new char[300];
In order to accomplish this, you must capture the user input one char at a time using a loop. As you are capturing the chars you need to be clever enough to count the chars as you are removing them from the input stream AND somehow use new and delete operators to create and destroy pointers (plural) to store the chars as you are removing them from the input stream. Remember that the new and delete operators work at RUN TIME NOT COMPILE time! So use them to allocate JUST THE EXACT AMOUNT OF MEMORY FOR THE ENTRY.
Below is an example of WHAT NOT TO DO!!!
const int ARRAY_SIZE =100;//bad idea
char *UserInputCharArray = nullptr;//this is correct
//allocate memory to the pointer
UserInputCharArray = new char[ARRAY_SIZE]; //you are allocating at compile time the size of the array; another VERYBAD idea!
This code above is NOT allowed because you are assuming the user will enter a string of exactly 100 chars. Unless you have a crystal ball and can guess that every user will enter a string of 100 chars every single time, DON'T do this. Others reasons why this is not allowed are:
If the user enters a four char entry like gaga, then you are wasting memory, by allocating memory for an array of 100 chars
If the user enters a four hundred char entry by typing gaga 100 times; then you are not allocating enough memory, to capture the entire entry!
HINT
char aChar;//declare a variable of type char
// Get a string. Prompt user
cout
//capture userInput, one char at a time
aChar = cin.get();
while (aChar != 10)
{
//your code goes here
}
RESTRICTIONS:
No global variables
No labels or go-to statements
No infinite loops
No break statements
You may use string literals, but do NOT use variables of type string!!!
EXPECTED OUTPUT:
Enter a string: 1234aeiouAEIOUandbingowashis name oh HA HAH HA please HELP me!!! The lower-case vowels which are present are: a (5)e (5)i (3)o (3)u (1) The upper-case vowels which are present are: A (4)E (2)I (1)0 (1)U (1) There is no highest frequency lower case vowel The highest frequency upper case vowel is A with a frequency of4 Press any key to continue To continue enter y or Y, anything else will quit the progranm Enter a string: AEIOUAAAAAAAAAAAAAAAHHHHHH Please send help!!! Oooooooo Ahhhhhh The lower-case vowels which are present are: a (1)e (4)o (7) The upper-case vowels which are present are: A (17)E (1)I (1)0 (2)U (1) The highest frequency lower case vowel is o with a frequency of 7 The highest frequency upper case vowel is A with a frequency of 17 Press any key to continue To continue enter y or Y, anything else will quit the progranm Enter a string: aeiouu u u uuu u The lower-case vowels which are present are: a (1)e (1)i (1)o (1)u (8) The highest frequency lower case vowel is u with a frequency of 8 There are no upper case vowels Press any key to continue To continue enter y or Y, anything else will quit the progranm Good-bye Press any key to continueStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started