Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8:37 PM Sun Mar 3 63%- Code Expectations Your program should only get user input from the command line. (i.e. cin should not be anywhere

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
8:37 PM Sun Mar 3 63%- Code Expectations Your program should only get user input from the command line. (i.e. cin" should not be anywhere in your code). Required Functions: o Function that prints program usage message in case no input strings were found at command line Name: printUsagelnfo Parameter(s): a string representing the name of the executable from the command line. (Not a c string) Return: void. Function that determines whether a string is a character-unit palindrome. o Name: isPalindrome Parameter(s): an input string, a boolean flag that considers case-sensitivity when true, and a boolean flag that ignores spaces when true. (Not a c string) Return: bool. Calls helper function isPalindromeR to determine whether string is a palindrome. String passed into isPalindromeR after dealing with flags. o If case insensitive, make all lower or upper case so that case does not matter. o If spaces are ignored, remove spaces from string. Helper recursive function that determines whether a string is a o character-unit palindrome. This does not deal with flags Name: isPalindromeR Parameter(s): an input string (Not a c string) Return: bool All functions should be placed in a separate file following the code organization conventions we covered. . 8:38 PM Sun Mar 3 63%- Program Flow 1. Your program will take arguments from the command-line 2. Determine if you have enough arguments. If not, output a usage message and exit program. 3. If flags are present. 1. Process and set values to use when processing a palindrome. 4. Loop through remaining arguments which are all input strings: 1. Process each by calling isPalindrome function with flag values. 2. Output results Program Flow Notes: Any time you encounter a syntax error, you should print a usage e message and exit the program immediately. o E.g. an invalid flag Hints Remember rules for a good recursive function. Note: You could combine these into a single function. e.g o tolower convert each letter to lowercase version for case insensitive comparisons. Parameter(s): a string to be converted to lowercase Return: a string with all lowercase characters removePunctuation - Remove all punctuation marks possibly including spaces depending on the flag value. o Parameter(s): a string and a boolean flag indicating whether to also remove spaces Return: a string with punctuation/spaces removed . Existing functions that might help: o tolower o substr o isalnum 8:37 PM Sun Mar 3 63%- $ g++ . -o palindrome. /palindrome Usage: ./palindrome [-c] [-s] string.. -c turn on case sensitivity -s: turn off ignoring spaces /palindrome -c Usage: /palindrome [-c] [-s] string .. . -c turn on case sensitivity -s: turn off ignoring spaces /palindrome Kayak "Kayak" is a palindrome /palindrome -c Kayak "Kayak" is not a palindrome /palindrome -C Kayak "Kayak" is not a palindrome /palindrome -c kayak "kayak" is a palindrome /palindrome "Test Set" "Test Set" is a palindrome /palindrome -sc "Test Set" "Test Set" is not a palindrome /palindrome -s-"Test Set" "Test Set" is not a palindrome Palindromes o o o substr isalnum erase (This can be used instead of substr, but is a bit more complicated.) . Development Environment (applies only to those using an IDE): Since you will be using command line parameters, you will need to figure out how to add command line parameters in your IDE. In Eclipse, when you get to Run As, select "Run Configurations..." Instead of "1 Local C/C++ Application" In the resulting window, click on the "Arguments" tab. You can run the command line arguments there. o Example Output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

More Books

Students also viewed these Databases questions

Question

Select suitable tools to analyze service problems.

Answered: 1 week ago