MindTap - Cengage Learning - Microsoft Edge A https://ng.cengage.com/static/nb/ui/evo/index.html?deploymentld=57811235846758605217306036&elSBN=9781337274715&id=710937854&snapshotld=1589550& >> CENGAGE MINDTAP Q Search this course Programming Exercise 6-1 Instructions main.cpp >- Terminal 1 #include main.cpp: In function 'int main ()': main.cpp:31:3: еггог: еxреcted primary-expression before ' t oken /s/.isPalindrome("Madam") > n 2 #include Instructions A-Z 4 using namespace std; Write a program that uses the function </> 6 //My user defined function that checks whether given string is palindrome 7 bool isPalindrome(string str) isPalindrome given in Example 6-6 main.cpp:31:6: еггог: еxpected primary-expression before .'t oken /s/.isPalindrome("Madam") > n (Palindrome). Test your program on the 8 { following strings: 9. //Finding the string length 10 int length = str.length(); 11 madam, abba, 22, 67876, 444244, trymeuemyi main.cpp:41:8: error: “i' was n ot declared in this scope for (i = 0; i < 6; i++) 12 //Iterating over string 13 for (int i = 0; i < length / 2; i++) 14 { /bin/bash: line 4: ./a.out: No such file or directory 15 //Converting both characters into lower-case and then comparing them, bongo Modify the function isPalindrome of //So now, the comparison function will ignore the case if (tolower(str[i]) != tolower(str[length - 1 - i])) { return false; 16 Example 6-6 so that when determining 17 whether a string is a palindrome, cases are 18 19 ignored, that is, uppercase and lowercase 20 } letters are considered the same. 21 //string is a palindrome 22 return true; The isPalindrome function from Example 23 6-6 has been included below for your 24 convenience. 25 //Define the main function 26 int main() bool isPalindrome(string str) 11:05 PM P Type here to search Answered: I have a .. MindTap - Cengag.. main.cpp - Notepad 4/10/2020

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
100%

I Hope you can understand that my programming needs.

Here's the instructions again 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

Here's my code so far:

#include <iostream>
#include <string.h>

using namespace std;

//My user defined function that checks whether given string is palindrome
bool isPalindrome(string str)
{
//Finding the string length
int length = str.length();

//Iterating over string
for (int i = 0; i < length / 2; i++)
{
//Converting both characters into lower-case and then comparing them,
//So now, the comparison function will ignore the case
if (tolower(str[i]) != tolower(str[length - 1 - i])) {
return false;
}
}
//String is a palindrome
return true;
}

//Define the main function
int main()
{
//Array of strings

string s[7] = {"Madam", "22", "abBa", "67876", "444244", "trYmeuemyRT"};
/s/.isPalindrome("Madam") ~=> ~<MatchData "i">
/s/.isPalindrome("22") ~=> ~<MatchData "i">
/s/.isPalindrome("abBa") ~=> ~<MatchData "i">
/s/.isPalindrome("67876") ~=> ~<MatchData "i">
/s/.isPalindrome("444244") ~=> ~<MatchData "i">
/s/.isPalindrome("trYmeuemyRT") ~=> ~<MatchData "i">

int i;

//Checking five strings
for (i = 0; i < 6; i++)
{
//Testing the boolean isPalindrome user defined function against the string variables.
if (isPalindrome(s[i]))
{
cout << "\n " << s[i] << " is a palindrome";
}
else
{
cout << "\n " << s[i] << " is not a palindrome";
}

}
return 0;
}

I already get that if the following code is removed, the program will execute properly:

/s/.isPalindrome("Madam") ~=> ~<MatchData "i">
/s/.isPalindrome("22") ~=> ~<MatchData "i">
/s/.isPalindrome("abBa") ~=> ~<MatchData "i">
/s/.isPalindrome("67876") ~=> ~<MatchData "i">
/s/.isPalindrome("444244") ~=> ~<MatchData "i">
/s/.isPalindrome("trYmeuemyRT") ~=> ~<MatchData "i">

That's the problem! If I remove them, and execute the code, it will print out the desired output, but that will only account for 40% of the grade! I will still fail the lab miserably! The above code is required to have 100% completion, and that's my goal!

If you would humor me please, Please look at the screen shot I've sent along. According to the lab's complier, their are only 3 errors left to accomidate. I don't know how to fix these errors, but when they are fixed, I could run the program, and then get the full grade.

However, I'm not sure that I have inputted the correct regular expressions. According to the lab, I'm using the correct expressions, but I believe that in each line, the corresponding ~<MatchData "i"> isn't correct. Am I supposed to match it to s[7] in line 30, or should I match it to s[i] in line 44? If I'm right, please tell me how to code it right.

Also, as I said before, I'm not sure if these regular expressions should be placed here at lines 31-36, or if they should be placed somewhere else in the program. I'm concerned that the reason why I'm having so much trouble with this program is because of where I have inputted these expressions. That means if I'm right, the problem would be fixed quickly if they are placed in the correct location (if there is another location). Please help me! I'm desperate, and I can't spend another week fixing another program! I need help!

MindTap - Cengage Learning - Microsoft Edge
A https://ng.cengage.com/static/nb/ui/evo/index.html?deploymentld=57811235846758605217306036&elSBN=9781337274715&id=710937854&snapshotld=1589550&
>>
CENGAGE MINDTAP
Q Search this course
Programming Exercise 6-1
Instructions
main.cpp
>- Terminal
1 #include <iostream>
main.cpp: In function 'int main
()':
main.cpp:31:3: еггог: еxреcted
primary-expression before ' t
oken
/s/.isPalindrome("Madam")
> n<MatchData "i">
2 #include <string.h>
Instructions
A-Z
4 using namespace std;
Write a program that uses the function
</>
6 //My user defined function that checks whether given string is palindrome
7 bool isPalindrome(string str)
isPalindrome given in Example 6-6
main.cpp:31:6: еггог: еxpected
primary-expression before .'t
oken
/s/.isPalindrome("Madam")
> n<MatchData "i">
(Palindrome). Test your program on the
8 {
following strings:
9.
//Finding the string length
10
int length = str.length();
11
madam, abba, 22, 67876, 444244, trymeuemyi
main.cpp:41:8: error: “i' was n
ot declared in this scope
for (i = 0; i < 6; i++)
12
//Iterating over string
13
for (int i = 0; i < length / 2; i++)
14
{
/bin/bash: line 4: ./a.out: No
such file or directory
15
//Converting both characters into lower-case and then comparing them,
bongo
Modify the function isPalindrome of
//So now, the comparison function will ignore the case
if (tolower(str[i]) != tolower(str[length - 1 - i])) {
return false;
16
Example 6-6 so that when determining
17
whether a string is a palindrome, cases are
18
19
ignored, that is, uppercase and lowercase
20
}
letters are considered the same.
21
//string is a palindrome
22
return true;
The isPalindrome function from Example
23
6-6 has been included below for your
24
convenience.
25 //Define the main function
26 int main()
bool isPalindrome(string str)
11:05 PM
P Type here to search
Answered: I have a ..
MindTap - Cengag..
main.cpp - Notepad
4/10/2020
Transcribed Image Text:MindTap - Cengage Learning - Microsoft Edge A https://ng.cengage.com/static/nb/ui/evo/index.html?deploymentld=57811235846758605217306036&elSBN=9781337274715&id=710937854&snapshotld=1589550& >> CENGAGE MINDTAP Q Search this course Programming Exercise 6-1 Instructions main.cpp >- Terminal 1 #include <iostream> main.cpp: In function 'int main ()': main.cpp:31:3: еггог: еxреcted primary-expression before ' t oken /s/.isPalindrome("Madam") > n<MatchData "i"> 2 #include <string.h> Instructions A-Z 4 using namespace std; Write a program that uses the function </> 6 //My user defined function that checks whether given string is palindrome 7 bool isPalindrome(string str) isPalindrome given in Example 6-6 main.cpp:31:6: еггог: еxpected primary-expression before .'t oken /s/.isPalindrome("Madam") > n<MatchData "i"> (Palindrome). Test your program on the 8 { following strings: 9. //Finding the string length 10 int length = str.length(); 11 madam, abba, 22, 67876, 444244, trymeuemyi main.cpp:41:8: error: “i' was n ot declared in this scope for (i = 0; i < 6; i++) 12 //Iterating over string 13 for (int i = 0; i < length / 2; i++) 14 { /bin/bash: line 4: ./a.out: No such file or directory 15 //Converting both characters into lower-case and then comparing them, bongo Modify the function isPalindrome of //So now, the comparison function will ignore the case if (tolower(str[i]) != tolower(str[length - 1 - i])) { return false; 16 Example 6-6 so that when determining 17 whether a string is a palindrome, cases are 18 19 ignored, that is, uppercase and lowercase 20 } letters are considered the same. 21 //string is a palindrome 22 return true; The isPalindrome function from Example 23 6-6 has been included below for your 24 convenience. 25 //Define the main function 26 int main() bool isPalindrome(string str) 11:05 PM P Type here to search Answered: I have a .. MindTap - Cengag.. main.cpp - Notepad 4/10/2020
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Datatypes
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.
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