C++ Define a class called MyString. MyString should contain a Menu as follow:                       My first MyString Menu Option Cost ======================================= 1. Create a substring    $5        2. Find a reference $10        3. Remove part of the string $7        4. Add two strings to each other $4        5. Check if a string is empty $1        6. Check if two strings are equal $6        7. Insert a string inside another string $3        8. Exit   The user will enter two strings str1 and str2 and should be able to keep selecting options until option 8 is selected (exit). After each selection the cost amount will change. At the end of each selection you should print out the result and at the end printout the following: Your total cost is: $15        (or whatever is the sum)

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

C++

Define a class called MyString.

MyString should contain a Menu as follow:

 

                    My first MyString Menu

Option Cost

=======================================

1. Create a substring    $5

       2. Find a reference $10

       3. Remove part of the string $7

       4. Add two strings to each other $4

       5. Check if a string is empty $1

       6. Check if two strings are equal $6

       7. Insert a string inside another string $3

       8. Exit

 

The user will enter two strings str1 and str2 and should be able to keep selecting options until option 8 is selected (exit). After each selection the cost amount will change. At the end of each selection you should print out the result and at the end printout the following:

Your total cost is: $15        (or whatever is the sum)  

(Hint: for the functions use table 1 and table 2)

Table 1

 

 

EXAMPLE
strl + str2
str.insert(pos,
str2)
str.remove(pos, length)
Comparisons
str1== str2 str1 != str2
str1<str2
str1> str2
str1 <= str2 strl >= str2
str.find(str1)
str.find(str1, pos)
str.find_first_of(str1, pos)
str.find_first_not_of
(str1, pos)
REMARKS
Returns a string that has str2's data concatenated to the
end of strl's data. The size is set appropriately.
Inserts str2 into str beginning at position pos.
Removes substring of size length, starting at position pos.
Compare for equality or inequality; returns a Boolean value.
Four comparisons. All are lexicographical comparisons.
Returns index of the first occurrence of str1 in str.
Returns index of the first occurrence of string str1 in str;
the search starts at position pos.
Returns the index of the first instance in str of any character
in str1, starting the search at position pos.
Returns the index of the first instance in str of any character
not in str1, starting search at position pos.
Transcribed Image Text:EXAMPLE strl + str2 str.insert(pos, str2) str.remove(pos, length) Comparisons str1== str2 str1 != str2 str1<str2 str1> str2 str1 <= str2 strl >= str2 str.find(str1) str.find(str1, pos) str.find_first_of(str1, pos) str.find_first_not_of (str1, pos) REMARKS Returns a string that has str2's data concatenated to the end of strl's data. The size is set appropriately. Inserts str2 into str beginning at position pos. Removes substring of size length, starting at position pos. Compare for equality or inequality; returns a Boolean value. Four comparisons. All are lexicographical comparisons. Returns index of the first occurrence of str1 in str. Returns index of the first occurrence of string str1 in str; the search starts at position pos. Returns the index of the first instance in str of any character in str1, starting the search at position pos. Returns the index of the first instance in str of any character not in str1, starting search at position pos.
EXAMPLE
Constructors
string str;
string str("string");
string str(aString);
Element access
str[i]
str.at (i)
str.substr(position, length)
Assignment/Modifiers
: str2;
str1 =
strl + str2;
str.empty()
REMARKS
Default constructor; creates empty string object str.
Creates a string object with data "string".
Creates a string object str that is a copy of aString.
aString is an object of the class string.
Returns read/write reference to character in str at index i.
Returns read/write reference to character in str at index i.
Returns the substring of the calling object starting at posi-
tion and having length characters.
Allocates space and initializes it to str2's data, releases
memory allocated for str1, and sets strl's size to that of
str2.
Character data of str2 is concatenated to the end of str1;
the size is set appropriately.
Returns true if str is an empty string; returns false
otherwise.
Transcribed Image Text:EXAMPLE Constructors string str; string str("string"); string str(aString); Element access str[i] str.at (i) str.substr(position, length) Assignment/Modifiers : str2; str1 = strl + str2; str.empty() REMARKS Default constructor; creates empty string object str. Creates a string object with data "string". Creates a string object str that is a copy of aString. aString is an object of the class string. Returns read/write reference to character in str at index i. Returns read/write reference to character in str at index i. Returns the substring of the calling object starting at posi- tion and having length characters. Allocates space and initializes it to str2's data, releases memory allocated for str1, and sets strl's size to that of str2. Character data of str2 is concatenated to the end of str1; the size is set appropriately. Returns true if str is an empty string; returns false otherwise.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Knowledge Booster
Data members
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