Question

Please provide answer in the format that I provided, thank you Write a program that prompts...

Please provide answer in the format that I provided, thank you

Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel.

You must insert the following comments at the beginning of your program and write our commands in the middle:

Write a C++ Program:

/*

// Name: Your Name

// ID: Your ID

// Purpose Statement:~~~

*/

#include <iostream>

#include <string>

using namespace std;

void removeVowels(string& str);

bool isVowel(char ch);

int main()

{

    string str;

    cout << "Enter a string: ";

    …

    …

         YOUR CODE HERE

    …

    …

return 0;

}

void removeVowels(string& str)

{

    int len = str.length();

    …

    …

         YOUR CODE HERE

    …

    …

}

bool isVowel(char ch)

{

    switch (ch)

    …

    …

         YOUR CODE HERE

    …

    …

}

Homework Answers

Answer #1

#include <iostream>

#include <string>

using namespace std;

void removeVowels(string &str);

bool isVowel(char ch);

int main()

{

    string str;

    cout << "Enter a string: ";

    // YOUR CODE HERE

    cin >> str;

    // remove all vowels

    removeVowels(str);

    cout << "String after removing vowels: " << str;

    return 0;

}

void removeVowels(string &str)

{

    int len = str.length();

    // YOUR CODE HERE

    int i = 0;

    while (i < len)

    {

        // if current char is vowel

        if (isVowel(str[i]))

        {

            // remove char

            str = str.substr(0, i) + str.substr(i + 1, len);

            len = str.length();

        }

        else

            i++;

    }

}

bool isVowel(char ch)

{

    switch (ch)

    {

        // YOUR CODE HERE

    case 'a':

    case 'A':

    case 'e':

    case 'E':

    case 'i':

    case 'I':

    case 'o':

    case 'O':

    case 'u':

    case 'U':

        return true;

    default:

        return false;

    }

}

.

Output:

.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a program that reads in a line consisting of a student’s name, Social Security number,...
Write a program that reads in a line consisting of a student’s name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number and all the characters in the password are replaced by x. (The Social Security number is in the form 000-00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [] to access a string element....
C++ Write a recursive function that reverses the given input string. No loops allowed, only use...
C++ Write a recursive function that reverses the given input string. No loops allowed, only use recursive functions. Do not add more or change the parameters to the original function. Do not change the main program. I had asked this before but the solution I was given did not work. #include #include using namespace std; void reverse(string &str) { /*Code needed*/ } int main() {    string name = "sammy";    reverse(name);    cout << name << endl; //should display...
Trying to pass a pointer through the function bool CustomerList::updateStore() that will allow me to modify...
Trying to pass a pointer through the function bool CustomerList::updateStore() that will allow me to modify an input. Ex. (1234, "Name", "Street Address", "City", "State", "Zip") Using the function bool CustomerList::updateStore() Updating..successful New Address: (0001, "Store", "111 Main St.", "Townsville", "GA", "67893") CustomerList.h #pragma once; #include #include "Store.h" class CustomerList {    public:        Store *m_pHead;        CustomerList();        ~CustomerList();        bool addStore(Store *s);        Store *removeStore(int ID);        Store *getStore(int ID);       ...
can you please do this lab? use lunix or C program its a continuation of a...
can you please do this lab? use lunix or C program its a continuation of a previous lab. the previous lab: Unix lab 4: compile and link multiple c or c++ files Please do the following tasks step by step: create a new directory named by inlab4 enter directory inlab4 create a new file named by reverse.c with the following contents and then close the file: /*reverse.c */ #include <stdio.h> reverse(char *before, char *after); main() {       char str[100];    /*Buffer...
Program C++ (use visual studio) Q1. What default copy constructor does the compiler insert in the...
Program C++ (use visual studio) Q1. What default copy constructor does the compiler insert in the following class? class Student { string name; string id; double grade; }; =========================== Q2 .What is the factor transfer method used when the f() function is called from? void f(int n[]); int main() { int m[3]= {1, 2, 3}; f(m); } ================================== Q3. Write a program that produces a bigger() with a prototype as shown below and outputs a large value by inputting two...
Create a program which uses each struct declared in problem 1 and accesses each member of...
Create a program which uses each struct declared in problem 1 and accesses each member of each struct. (a) Create a variable using each struct and initialize it with some mock data of your choosing. (b) Print the members of each struct separated by a newline. (c) Modify each member of each struct to something different. (d) Print all members again. Save your code as prob2.c. This is Problem 1: struct ProductData {     int ID;     char Name[50];     float Price;     int...
/* Write a function that looks for a particular person in their respective linked list The...
/* Write a function that looks for a particular person in their respective linked list The only place you need to write code is the "find" method in the linked list class */ #include <bits/stdc++.h> using namespace std; string ltrim(const string &); string rtrim(const string &); #define BUFFLEN 10 /* Each "person" is defined by their name, zipcode, and their pet's name. Persons are hashed by their zipcode. */ //---------------------------------------------------------------------------- /* function declarations ------------------------*/ int computeKey(int); void add_to_buffer(string,int,string); void find_in_buffer(int);...
The following program implements a key-value data structure in which values are stored based on a...
The following program implements a key-value data structure in which values are stored based on a string keyword. Currently, the program allows new keys and values to be entered, but there is no function to retrieve the values given a search key. Complete the get_value function to retrieve a value given a search key. The function should print "INVALID KEY" if the key is not present. Do not remove any code OR add any code to main. You should only...
Implement and demonstrate a disk-based buffer pool class based on the LRU buffer pool replacement strategy....
Implement and demonstrate a disk-based buffer pool class based on the LRU buffer pool replacement strategy. Disk blocks are numbered consecutively from the beginning of the file with the first block numbered as 0. Assume that blocks are 4096 bytes in size. Use the supplied C++ files to implement your LRU Buffer Pool based on the instructions below. • Implement a BufferBlock class using the supplied BufferBlockADT.h o Your Buffer Block must inherit BufferBlockADT or you will not get credit...
please use linux/unix command terminal to complete, step 1 1-create a new directory named by inlab4...
please use linux/unix command terminal to complete, step 1 1-create a new directory named by inlab4 enter directory inlab4 create a new file named by reverse.c with the following contents and then close the file: /*reverse.c */ #include <stdio.h> reverse(char *before, char *after); main() { char str[100]; /*Buffer to hold reversed string */ reverse("cat", str); /*Reverse the string "cat" */ printf("reverse(\"cat\")=%s\n", str); /*Display result */ reverse("noon", str); /*Reverse the string "noon" */ printf("reverse(\"noon\")=%s\n", str); /*Display result */ } reverse(char *before,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT