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.

Remember to comment your code

Use meaningful or memonic 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 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:

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 allocatingenough memory, to capture the entire entry!

HINT

char aChar;//declare a variable of type char

// Get a string. Prompt user

cout << "Enter a string: ";

//capture userInput, one char at a time

aChar = cin.get();

while (aChar != 10)

{

//your code

}

This is the book we are currently using.. "Starting Out With Cpp From Control Structures Through Objects 8th Edition" Chapter 10.

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

Question Can a Roth IRA invest in stock of the IRA owners business?

Answered: 1 week ago