In C++, please revise/fix the program below according to the instructions and all the criteria. I believe the problem is in int main(). Thank you. Instruction Write and test a function that returns a copy of its string parameter with no repeated characters. The functions ignore case when they compare letters. The functions return strings whose letters are upper case. Write 2 versions of the function: string remDups(const string& original); void remDups(const string& original, string& nodups); Suppose the original string is “Myrtle has big feet” The function returns MYRTLE HASBIGF Test the functions thoroughly.   Criteria compile, run, test the test program compiles, runs, and calls both versions of the function without crashing the test program tests the functions thoroughly function parameters and returns one function has one constant string reference parameter and returns a string one function has one constant string reference parameter, one string reference parameter and returns void. function operations the function removes all repeated characters from a copy of the original string the function ignores case the function converts the letters in the edited copy to upper case. the function returns the edited copy of the original string the edited copy of the original strings contains no repeated characters the function uses only string and character functions the best solutions use one loop, one conditional statement, one string function, and one character function.  C++ code #include #include #include   using namespace std;   std::string& remDups(std::string& original)   {        int length = original.length();        for (unsigned int i = 0; i < length; i++)        {               char currChar = original[i]; //holds current character               for (unsigned int j = i + 1; j < length; j++)               {                      if (currChar == original[j])                            original.erase(std::remove(original.begin() + j, original.end(), original[j]), original.end());               }        }        return original; }   void remDups(const string& original, string& nodups) {        transform(nodups.begin(), nodups.end(), nodups.begin(), ::toupper);          std::cout << "New String is " << nodups << "\n";   }   int main() {        std::string str, str1;        std::cout << "Enter string \n";        std::getline(std::cin, str);        str1 = remDups(str);        remDups(str, str1);          return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In C++, please revise/fix the program below according to the instructions and all the criteria. I believe the problem is in int main(). Thank you.

Instruction

Write and test a function that returns a copy of its string parameter with no repeated characters. The functions ignore case when they compare letters. The functions return strings whose letters are upper case.

Write 2 versions of the function:

string remDups(const string& original);

void remDups(const string& original, string& nodups);

Suppose the original string is “Myrtle has big feet”

The function returns MYRTLE HASBIGF

Test the functions thoroughly.

 

Criteria

compile, run, test

the test program compiles, runs, and calls both versions of the function without crashing
the test program tests the functions thoroughly

function parameters and returns

one function has one constant string reference parameter and returns a string
one function has one constant string reference parameter, one string reference parameter and returns void.

function operations

the function removes all repeated characters from a copy of the original string
the function ignores case
the function converts the letters in the edited copy to upper case.
the function returns the edited copy of the original string

the edited copy of the original strings contains no repeated characters
the function uses only string and character functions
the best solutions use one loop, one conditional statement, one string function, and one character function.

 C++ code

#include <iostream>

#include <string>

#include <algorithm>

 

using namespace std;

 

std::string& remDups(std::string& original)

 

{

       int length = original.length();

       for (unsigned int i = 0; i < length; i++)

       {

              char currChar = original[i]; //holds current character

              for (unsigned int j = i + 1; j < length; j++)

              {

                     if (currChar == original[j])

                           original.erase(std::remove(original.begin() + j, original.end(), original[j]), original.end());

              }

       }

       return original;

}

 

void remDups(const string& original, string& nodups)

{

       transform(nodups.begin(), nodups.end(), nodups.begin(), ::toupper);

 

       std::cout << "New String is " << nodups << "\n";

 

}

 

int main()

{

       std::string str, str1;

       std::cout << "Enter string \n";

       std::getline(std::cin, str);

       str1 = remDups(str);

       remDups(str, str1);

 

       return 0;

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Algebraic Expressions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education