Concept explainers
Palindrome Testing
A palindrome is a string that reads the same backward as forward. For example, the words worn, dad, madam and radar are all palindromes. Write a class Pstring that is derived from the STL string class. The Pstring class adds a member function
bool isPalindrome( )
that determines whether the string is a palindrome. Include a constructor that takes an STL string object as parameter and passes it to the string base class constructor. Test your class by having a main
You may find it useful to use the subscript operator [ ] of the string class: If str is a string object and k is an integer, then str[k] returns the character at position k in the string.
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
Starting Out with C++: Early Objects (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (3rd Edition)
Starting Out with Programming Logic and Design (4th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Problem Solving with C++ (9th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
- the function returns the result as a string if the expression is legal. the expression returns an empty string and then put the function public class Ez1MathEval {public String heavywtEval (String exprn) {return ""}}arrow_forwardHomework 10-1 Programming Challenge: 2 - Backwards String Write a function that accepts a string and returns a string in which the contents are the reverse of the original string, and a program in which this function is demonstrated. The prototype is string reverseString(const string &); This might need a little explanation. We want to pass the string by reference (as is customary for objects) but we don't want the function to make any changes to our string. Thus, we pass as a "constant reference." Newer languages like Java do this automatically; if you pass an object to a Java method, it's handled internally kind of like this, as a constant reference to that object. Any changes made to the object within the function are strictly local; the original object is unchanged. So our function will return a brand new string with contents equal to the reverse of the string sent to the function.arrow_forwardIN C++ Write code that: creates 3 integer values - one can be set to 0, the other two should NOT multiples of one another (for example 3 and 6, or 2 and 8) take you largest value and perform a modulus operation using the smaller (non zero) value as the divisor print out the result. create an alias for the string type call the alias "name" then create an instance of the "name" class and assign it a value using an appropriate cout statement - print out the value Please screenshot your input and output, as the format tends to get messed up. Thank you!arrow_forward
- 1. Use the Python to declare the following classes. Hint: Document is the parent class, and Book and Email are child classes inheriting the document class. Document -authors : String[ ] -date : Date +getAuthors() : String[ ] +addAuthor(name) : void +getDate() : date Вook EMail -title : String -subject : String -to : String[ ] +getTitle() : String +getSubject() : String +getTo() : String[ ] 2. Use O(n) to measure the following formular 10000 + log (n) + n Answer: • n? + nlog (n) + 5000 n Answer: 2 n20 + 2" Answer:arrow_forwardAlert dont submit AI generated answer.arrow_forward/* coding rules 1. dont call upon the library 2. Dont channge the coding formate 3. fill in the declartions by calling upon the contrusctor 4. Instructions are left in the declaration */ #include using namespace std; class My_String { public: // run the string as a constructor and is where string will be called upon in the class My_String( ){ char userinput [32000]; } void length(){ // returns the amount of charaters in the string. Spaces numbers symbols, etc. Also ensure to check if its empty or not } void Isalpha (){ // check to see if its a (a-z A-Z) and check to see of stromg input contains speccial characters or numbers and output location of non-aphabetical character } void Toupper() { // convert string lower case to upper case } void Tolower (){ // convert string upper case to lower case } void…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT