

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CSE294A Assignment # Professor Miller 1/
CSE294A Assignment # 4% of course grade
This assignment is going to give you experience manipulating strings and using C string functions.
You will start off by reading a string from the user. After reading the string, you will prompt the user to see if he would like for you to determine whether the string is a
palindrome (the same forwards as backwards) or to determine if subsequent words are
subโanagrams. A subโanagram is a word that can be made from a subset of the letters in a word. If the user selects the subโanagram option, you will then prompt him to enter
another string, from which you will determine if the second string is a subโanagram of
the first. If so, you will tell the user; if not, you will tell the user which characters violate the subโanagram property.
Continue to allow the user to enter candidate subโanagram strings until he enters \q, in which case you will return to prompting the user to enter the first string again. From
the first string prompt, if the user enters \q, you will display a thank you message and
then exit the program.
Your program will be caseโinsensitive, meaning that it doesnโt matter if the user enters the initial phrase using capital or lowercase letters. Your program will also be
whitespaceโinsensitive, meaning that it doesnโt matter if there are spaces or tabs in the
input โ they will be ignored by your program.
There are two cases when phrases are not subโanagrams of the original word โ when a
character is used that is not in the original word, or when a character is used more than the number of times it appears in the original word. The output for each case is
different, as can be seen below in the sample execution.
When prompting the user to enter yes or no, it doesnโt matter if the word is entered
with capital or lowercase letters, but if the user does not type โyesโ or โnoโ, you will
prompt them with the same question again.
The output should be exactly the same as what is listed below.
CSE294A Assignment # Professor Miller 2/
Here is a sample execution (user input is bolded):
Enter a word or phrase (or \q to quit): race car Would you like to see if the phrase is a palindrome? ye Would you like to see if the phrase is a palindrome? yes The phrase โrace carโ IS a palindrome.
Would you like to play the sub-anagram game? Yes Enter a potential sub-anagram phrase (or \q to go back): jeff โjeffโ is NOT a sub-anagram of โrace carโ โrace carโ does not contain a โjโ โrace carโ does not contain a โfโ โrace carโ does not contain a โfโ
Enter a potential sub-anagram phrase (or \q to go back): care โcareโ IS a sub-anagram of โrace carโ
Enter a potential sub-anagram phrase (or \q to go back): rarer โrarerโ is NOT a sub-anagram of โrace carโ โrace carโ does not contain 3 rโs
Enter a potential sub-anagram phrase (or \q to go back): \q
Enter a word or phrase (or \q to quit): Hello World Would you like to see if the phrase is a palindrome? no
Would you like to play the sub-anagram game? YES Enter a potential sub-anagram phrase (or \q to go back): dell row โdell rowโ IS a sub-anagram of โhello worldโ
Enter a potential sub-anagram phrase (or \q to go back): \q
Enter a word or phrase (or \q to quit): \q
Thank you for using my program!
Grading Criteria 0.5% prompting the user as shown above 0.5% requiring the user to enter โyesโ or โnoโ to the questions 0.5% correctly handling \q for exiting the program 0.5% correctly handling \q for exiting the sub-anagram game 0.5% correctly determining if a word is a palindrome 0.5% correctly determining if a word is a sub-anagram of the original word 0.5% correctly displaying characters that were not in the original word in the sub-anagram game 0.5% correctly displaying the error if the original word does not contain the number of characters used in the candidate sub-anagram