Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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. THIS IS THE POINT OF THE QUIZ

-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:

1.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];

2.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];

3.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 in 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 VERY BAD 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, DONT do this. Others reasons why this is not allowed are:

1.If the user enters a four char entry like gaga, then you are wasting memory, by allocating memory for an array of 100 chars

2.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 c

out << "Enter a string: ";

//capture userInput, one char at a time

aChar = cin.get(); while (aChar != 10)

{ //your code }

GENERAL RESTRICTIONS

No global variables

No labels or go-to statements

No infinite loops, examples include: for(;;) while(1) while(true) do{//code}while(1);

No break statements to exit loops

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

How to find if any no. is divisble by 4 or not ?

Answered: 1 week ago

Question

Explain the Pascals Law ?

Answered: 1 week ago

Question

What are the objectives of performance appraisal ?

Answered: 1 week ago

Question

10. Are you a. a leader? b. a follower? _______

Answered: 1 week ago