Here are my instructions for my C++ program: Write a program that uses the function isPalindrome given in Example 6-6 (Palindrome). Test your program on the following strings: madam, abba, 22, 67876, 444244, trymeuemyrt Modify the function isPalindrome of Example 6-6 so that when determining whether a string is a palindrome, cases are ignored, that is, uppercase and lowercase letters are considered the same. The isPalindrome function from Example 6-6 has been included below for your convenience. bool isPalindrome(string str) { int length = str.length(); for (int i = 0; i < length / 2; i++) { if (str[i] != str[length – 1 – i]) { return false; } // if } // for loop return true; }// isPalindrome Your program should print a message indicating if a string is a palindrome: madam is a palindrome   The lab values require that I have the following string patterns in my lab: .+*isPalindrome\(\"Madam\"\).+* .+*isPalindrome\(\"abBa\"\).+* .+*isPalindrome\(\"22\"\).+* .+*isPalindrome\(\"67876\"\).+* .+*isPalindrome\(\"444244\"\).+* .+*isPalindrome\(\"trYmeuemyRT\"\).+*

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

Here are my instructions for my C++ program:

Write a program that uses the
function isPalindrome given in
Example 6-6 (Palindrome). Test
your program on the following
strings:

madam, abba, 22, 67876, 444244, trymeuemyrt

Modify the function isPalindrome
of Example 6-6 so that when
determining whether a string is a
palindrome, cases are ignored, that
is, uppercase and lowercase letters
are considered the same.

The isPalindrome function from
Example 6-6 has been included
below for your convenience.

bool isPalindrome(string str)
{
int length = str.length();
for (int i = 0; i < length / 2; i++) {
if (str[i] != str[length – 1 – i]) {
return false;
} // if
} // for loop
return true;
}// isPalindrome

Your program should print a
message indicating if a string is a
palindrome:

madam is a palindrome

 

The lab values require that I have the following string patterns in my lab:

.+*isPalindrome\(\"Madam\"\).+*

.+*isPalindrome\(\"abBa\"\).+*

.+*isPalindrome\(\"22\"\).+*

.+*isPalindrome\(\"67876\"\).+*

.+*isPalindrome\(\"444244\"\).+*

.+*isPalindrome\(\"trYmeuemyRT\"\).+*

 

### Palindrome Function Testing

Below are the results of testing the function `isPalindrome`, which checks if a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization).

#### Test Results:

1. **Code Pattern:**
   - **Status:** Complete
   - **Description:** Uses function `isPalindrome`

2. **Test Case 1:**
   - **Status:** Incomplete
   - **Test Description:** Tested `isPalindrome` with the string argument "Madam"

3. **Test Case 2:**
   - **Status:** Incomplete
   - **Test Description:** Tested `isPalindrome` with the string argument "abBa"

4. **Test Case 3:**
   - **Status:** Incomplete
   - **Test Description:** Tested `isPalindrome` with the string argument "22"

5. **Test Case 4:**
   - **Status:** Incomplete
   - **Test Description:** Tested `isPalindrome` with the string argument "67876"

6. **Test Case 5:**
   - **Status:** Incomplete
   - **Test Description:** Tested `isPalindrome` with the string argument "444244"

7. **Test Case 6:**
   - **Status:** Incomplete
   - **Test Description:** Tested `isPalindrome` with the string argument "tRYmeuemyRT"

This list indicates that while the use of the function is implemented, several tests have not been completed to determine if the function accurately identifies palindromes in the given test cases. Further review and testing are required to ensure the function's reliability.
Transcribed Image Text:### Palindrome Function Testing Below are the results of testing the function `isPalindrome`, which checks if a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization). #### Test Results: 1. **Code Pattern:** - **Status:** Complete - **Description:** Uses function `isPalindrome` 2. **Test Case 1:** - **Status:** Incomplete - **Test Description:** Tested `isPalindrome` with the string argument "Madam" 3. **Test Case 2:** - **Status:** Incomplete - **Test Description:** Tested `isPalindrome` with the string argument "abBa" 4. **Test Case 3:** - **Status:** Incomplete - **Test Description:** Tested `isPalindrome` with the string argument "22" 5. **Test Case 4:** - **Status:** Incomplete - **Test Description:** Tested `isPalindrome` with the string argument "67876" 6. **Test Case 5:** - **Status:** Incomplete - **Test Description:** Tested `isPalindrome` with the string argument "444244" 7. **Test Case 6:** - **Status:** Incomplete - **Test Description:** Tested `isPalindrome` with the string argument "tRYmeuemyRT" This list indicates that while the use of the function is implemented, several tests have not been completed to determine if the function accurately identifies palindromes in the given test cases. Further review and testing are required to ensure the function's reliability.
**Title:** Palindrome Checking Program

**Description:**

A program designed to determine if a given string is a palindrome.

**Checks:**

- **Test Case:** Incomplete
  - **Description:** Test for palindromes
  - **Input:** Not specified
  - **Output:** "enter a string; is a palindrome"

**Results:**

- **madam is a palindrome**
- **Abba is a palindrome**
- **444244 is not a palindrome**
- **22 is a palindrome**
- **07070 is a palindrome**
- **%YYanaaYY% is a palindrome**

The program currently has 0 out of 1 checks passed, as indicated by the text "0 out of 1 checks passed. Review the results below for more details."

Users can run the checks again or submit the program for evaluation.
Transcribed Image Text:**Title:** Palindrome Checking Program **Description:** A program designed to determine if a given string is a palindrome. **Checks:** - **Test Case:** Incomplete - **Description:** Test for palindromes - **Input:** Not specified - **Output:** "enter a string; is a palindrome" **Results:** - **madam is a palindrome** - **Abba is a palindrome** - **444244 is not a palindrome** - **22 is a palindrome** - **07070 is a palindrome** - **%YYanaaYY% is a palindrome** The program currently has 0 out of 1 checks passed, as indicated by the text "0 out of 1 checks passed. Review the results below for more details." Users can run the checks again or submit the program for evaluation.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Your output was correct

The lab values require that I have the following string patterns in my lab:

Description

Searched your code for a specific pattern:

.+*isPalindrome\(\"Madam\"\).+*

.+*isPalindrome\(\"Madam\"\).+*

.+*isPalindrome\(\"abBa\"\).+*

.+*isPalindrome\(\"22\"\).+*

.+*isPalindrome\(\"67876\"\).+*

.+*isPalindrome\(\"444244\"\).+*

.+*isPalindrome\(\"trYmeuemyRT\"\).+*

### Palindrome Function Verification

#### Overview
This screen provides a progress report on palindrome function testing, showcasing your development in utilizing the `isPalindrome` function with required string arguments.

#### Test Summary
- **Score:** 10.00 out of 70.00
- **Check Status:** 1 out of 7 checks passed
- **Guidance:** Review the details below for improvement suggestions.

#### Detailed Checks

1. **Code Pattern: Function Usage**
   - **Status:** Complete
   - **Description:** Successfully uses the function `isPalindrome`.

2. **Code Pattern: Test with 'Madam'**
   - **Status:** Incomplete
   - **Description:** The function `isPalindrome` was not tested with the string argument `"Madam"`.

   *Details*: The code search was for the pattern: `.*isPalindrome\(.*"Madam".*\).*`

3. **Code Pattern: Test with 'aBbA'**
   - **Status:** Incomplete
   - **Description:** The function `isPalindrome` was not tested with the string argument `"aBbA"`.

#### Action Points
- Make sure to run tests using specific string arguments like `"Madam"` and `"aBbA"` to verify the functionality of your palindrome checker.

#### Code Snippet
The snippet included illustrates the implementation of `isPalindrome` in C++ using string manipulation to check palindrome status with character case insensitivity.

#### Suggestions for Improvement
- Utilize the `Run checks` button to re-evaluate your code after making necessary corrections.
- Explore regular expressions for more efficient pattern matching in your tests.

> Remember: Palindromes are strings that read the same forwards and backwards, disregarding case differences. Ensure your function handles this appropriately.
Transcribed Image Text:### Palindrome Function Verification #### Overview This screen provides a progress report on palindrome function testing, showcasing your development in utilizing the `isPalindrome` function with required string arguments. #### Test Summary - **Score:** 10.00 out of 70.00 - **Check Status:** 1 out of 7 checks passed - **Guidance:** Review the details below for improvement suggestions. #### Detailed Checks 1. **Code Pattern: Function Usage** - **Status:** Complete - **Description:** Successfully uses the function `isPalindrome`. 2. **Code Pattern: Test with 'Madam'** - **Status:** Incomplete - **Description:** The function `isPalindrome` was not tested with the string argument `"Madam"`. *Details*: The code search was for the pattern: `.*isPalindrome\(.*"Madam".*\).*` 3. **Code Pattern: Test with 'aBbA'** - **Status:** Incomplete - **Description:** The function `isPalindrome` was not tested with the string argument `"aBbA"`. #### Action Points - Make sure to run tests using specific string arguments like `"Madam"` and `"aBbA"` to verify the functionality of your palindrome checker. #### Code Snippet The snippet included illustrates the implementation of `isPalindrome` in C++ using string manipulation to check palindrome status with character case insensitivity. #### Suggestions for Improvement - Utilize the `Run checks` button to re-evaluate your code after making necessary corrections. - Explore regular expressions for more efficient pattern matching in your tests. > Remember: Palindromes are strings that read the same forwards and backwards, disregarding case differences. Ensure your function handles this appropriately.
The image shows a snippet of code and an output window from a programming exercise designed to identify palindromes. Here's the transcription and explanation:

---

**Output:**

- madam is a palindrome...
- abBa is a palindrome...
- 22 is a palindrome...
- 67876 is a palindrome...
- 444244 is not a palindrome...
- trYmeuemyRT is a palindrome...

**Results:**

- madam is a palindrome
- abBa is a palindrome
- 22 is a palindrome
- 444244 is not a palindrome
- trYmeuemyRT is a palindrome

**Expected Output:**

- madam is a palindrome
- abba is a palindrome
- 22 is a palindrome
- 67876 is a palindrome
- 444244 is not a palindrome
- trYmeuemyRT is a palindrome

---

**Explanation of the Code:**

The code consists of a function named `isPalindrome` which takes a string `str` as input and checks if it is a palindrome. It uses the following logic:

1. Calculate the length of the string.
2. Iterate over half of the string, comparing characters from the beginning and the end.
3. If any character pair does not match (considering case insensitivity), return `false`.
4. If all pairs match, return `true`.

**Observations:**

- The output section shows how different strings are evaluated to determine if they are palindromes.
- The "Results" section shows the actual output produced by the code.
- The "Expected Output" section provides the correct outputs for testing, which the program aims to match.

This exercise demonstrates basic string manipulation and comparison techniques in programming to identify palindromes effectively.
Transcribed Image Text:The image shows a snippet of code and an output window from a programming exercise designed to identify palindromes. Here's the transcription and explanation: --- **Output:** - madam is a palindrome... - abBa is a palindrome... - 22 is a palindrome... - 67876 is a palindrome... - 444244 is not a palindrome... - trYmeuemyRT is a palindrome... **Results:** - madam is a palindrome - abBa is a palindrome - 22 is a palindrome - 444244 is not a palindrome - trYmeuemyRT is a palindrome **Expected Output:** - madam is a palindrome - abba is a palindrome - 22 is a palindrome - 67876 is a palindrome - 444244 is not a palindrome - trYmeuemyRT is a palindrome --- **Explanation of the Code:** The code consists of a function named `isPalindrome` which takes a string `str` as input and checks if it is a palindrome. It uses the following logic: 1. Calculate the length of the string. 2. Iterate over half of the string, comparing characters from the beginning and the end. 3. If any character pair does not match (considering case insensitivity), return `false`. 4. If all pairs match, return `true`. **Observations:** - The output section shows how different strings are evaluated to determine if they are palindromes. - The "Results" section shows the actual output produced by the code. - The "Expected Output" section provides the correct outputs for testing, which the program aims to match. This exercise demonstrates basic string manipulation and comparison techniques in programming to identify palindromes effectively.
Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Function Arguments
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