Question

Although this question has been answered, I need it to be custom and use ASCII Characters...

Although this question has been answered, I need it to be custom and use ASCII Characters and the ord() function. home / study / engineering / computer science / computer science questions and answers / write a new function check_ispal(word) that takes a string input (word) and: (a) strips all ... Your question has been answered Let us know if you got a helpful answer. Rate this answer Question: Write a new function Check_ispal(word) that takes a string input (word) and: (a) strips all non-a... Write a new function Check_ispal(word) that takes a string input (word) and: (a) strips all non-alphanumeric characters (that is, all characters that are not lowercase/uppercase letters or numbers), from word, then (b) converts all uppercase letters in word to lowercase letters and finally, (c) calls ispal() (the one defined in the previous page) with the modified word string. So, when called this way: Check_ispal("A man, a plan, a canal: Panama‼"), it returns True, and Check_ispal("A Santa at NASA"), also returns True, and Check_ispal("Yawn... Madonna fan? No way!!"), also returns True. I’m giving you a head-start with a “skeleton code” to complete: skeleton code is def Check_ispal(word): print(word, end = ": ") newword = '' for c in word:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
using namespace std;
#include <locale>
#include <algorithm>
#include <string>
bool Check_isPal(string s) {
   int count = 0;
   string::size_type i = 0;
   while (i < s.length()) {
       if (isalnum(s[i])) count++;
       ++i;
   }
   if (count == s.length()) {
       return 1;
   }
}
string converter(string s) {
   int c;
   for (int i = 0; i < s.length(); i++) {
       if ((int)s[i] >= 64 && (int)s[i] <= 90) {
           c = (int)s[i] + 32;
           s[i] = (char)c;
       }
   }
   return s;
}
void isPal(string s)
{
   char c;
   for (int i = 0; i < s.length(); i++) {
       c = s[i];
       if ((int)s[i] < 48 || (int)s[i] > 122 || s[i]>9 && s[i]<65) {
           s.erase(std::remove(s.begin(), s.end(), c), s.end());
       }
   }
   std::cout << "After removing " << s << endl;
   s = converter(s);
   std::cout << "After converting:" << s << endl;
   cout << Check_isPal(s) << endl;
}

int main()
{
   cout << "Enter a string: ";
   string s = "A man, a plan, a canal: Panama‼";
   cout << "Inputted string is: " << s << endl;
   isPal(s);
  

   return 0;
}

P.S: STATEMENT IS WHOLE MIXED UP

IF YOU HAVE ANY DIFFICULTY PLEASE COMMENT DOWN BELOW

PLEASE GIVE A THUMBS UP

Add a comment
Know the answer?
Add Answer to:
Although this question has been answered, I need it to be custom and use ASCII Characters...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PLEASE USE MATLAB This is a basic problem that illustrates the concept of strings. A palidrome...

    PLEASE USE MATLAB This is a basic problem that illustrates the concept of strings. A palidrome is a string of characters that is read the same forwards as it is backwards. For example, racecar' is a palindrome; reversing the order of the characters leaves the string unchanged. Write a otherwise. function called isPalindrome that accepts one input and returns one output. The input str is a string of characters, and the output is 1 if str is a palindrome, For...

  • Create a Python script file called hw.py. Then import the module random: from random import *...

    Create a Python script file called hw.py. Then import the module random: from random import * Thanks in advance! Ex. 1. Write a function called cleanLowerWord that receives a string as a paramcter and retums a new string that is a copy of the parameter where all the lowercase letters are kept as such, uppercase letters are converted to lowercase, and everything else is deleted. For example, the function call cleanLowerWord("Hello, User 15!") should return the string "hellouser". For this,...

  • trouble with formatting titles :( Your friend is in charge of recording titles of books in...

    trouble with formatting titles :( Your friend is in charge of recording titles of books in the library they work in. Since they know you're in EECS 183, they've asked you to write a function that turns a lowercase string into Title Case format. This way, they can use the function to correctly format the titles without having to worry about capitalizing anything themselves. The function you will implement is stringToTitleCase, which takes a lowercase string str as input and...

  • C Program: Write the following function that takes a user input string, computes, and determines whether the input is palindromic or not by returning either true or false:

    A palindrome is a word, phrase, number, or other sequence of symbols or elements that reads the same forward or reversed. Examples: “Dad”, “Anna”, “Never odd or even”, etc. For this problem, we will only consider a string to be palindromic if its combined alpha-numeric characters (‘A’-’Z’, ‘a’-’z’, and ‘0’-’9’) can be read the same both forward and backward, by skipping all other non-alphanumeric characters.Write the following function that takes a user input string, computes, and determines whether the input is palindromic or not...

  • Write a method in java named isValidEmail that takes a string as input parameter, and returns...

    Write a method in java named isValidEmail that takes a string as input parameter, and returns true if that string represents a valid email address, or false otherwise. An email address is considered valid if it follows this format “user123@domain.ext”, where:  user123 represents a sequence of word characters (i.e., letters, digits, or underscore) whose length is between 1 and 10 (inclusive), but the first character must be a letter  domain represents a sequence of alphanumeric characters (i.e., letters...

  • can you use the isspace() method in the code what do i add to the code...

    can you use the isspace() method in the code what do i add to the code if i want to make sure that extra spaces dont affect the output of the code elect sumatra medium roast VS sumatra medium roast Det dat HETTI CV Surface Providesearch coffee record description to search for at that it was not found in the file the first on has another space in it Table 8-1 Some string testing methods Method Description isalnum() Returns true...

  • Using Python 3+ for Question P5.9 Instructions: Use one main() to call each of the functions...

    Using Python 3+ for Question P5.9 Instructions: Use one main() to call each of the functions you created. Only use one value of r and h for all the function. Ask the user for the r and h in the main() as an input, and h for all the functions. You should put the functions for areas in a separate file. ​ For example, firstDigtec7ze Write a function e digits n) (returning the number of digits in the argument returning...

  • C++ PROGRAMMING Implement a bool function whose header is given below. Inside the function, declare, ask,...

    C++ PROGRAMMING Implement a bool function whose header is given below. Inside the function, declare, ask, and get a character from the user. The function will return true if the character the user enters is NOT in either of the words, otherwise it will return false. Keep in mind that uppercase and lowercase letters are not the same. You will need to change both words and the character input by the user to the same case (upper or lower) -...

  • using basic c++ and use no functions from c string library b) Write a fragment of...

    using basic c++ and use no functions from c string library b) Write a fragment of code (with declarations) that reads a pair of words from the keyboard and determines how many letters in corresponding positions of each word are the same. The words consist only of the letters of the English alphabet (uppercase and lowercase). For example, if the words are coat and CATTLE, the following output should be generated: 012245 0122 matching letter in position 0 t is...

  • A palindrome is a word or phrase that reads the same both forwards and backwards. "racecar"...

    A palindrome is a word or phrase that reads the same both forwards and backwards. "racecar" is a palindrome. So is, "a man a plan a canal, panama" if you ignore the spacing and the comma. Discovering how to automate the detection of palindromes is a good way to test your understanding of loops and strings. The file, "hw2problem5.py", contains a function called is_palindrome(), which has a single string parameter, s. If s is a palindrome, then is_palindrome() returns the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT