Question: Assignment 4 CS 2 3 4 0 Fall 2 0 2 4 Palindromes A palindrome is a word or phrase that reads the same from

Assignment 4
CS2340 Fall 2024
Palindromes
A palindrome is a word or phrase that reads the same from left to right as right to left. A simple palindrome is kayak, for example. Other rules are that you ignore punctuation and letter case. For example, Madam, Im Adam is a palindrome despite commas, spaces, and upper and lower case differences. Palindromes can also contain digits, such as 12421.
Write a program that does the following:
1. Request a string from the user. If it is zero length (the first character is
) exit the program.
2. Determine if the string is a palindrome. If so, print Palindrome. If not, print Not a palindrome.
3. Return to request another string.
Program structure:
1. You can assume no input string is longer than 200 characters.
2. Write a helper function that calls three functions, as defined below. This structure is required. The parameter is the address of the input string in $a0.
a. Within this function, you must call another function that removes anything that isnt a letter or a number.
b. Within the second function, call a third function that converts lower case to upper case so your comparisons work properly.
c. You must write a function that determines whether the string is a palindrome. Call this with the address of the string in $a0 and no other parameters. This function must be recursive. That is, it must test whether the initial string might be a palindrome and return true if it the outer two characters match and false if they dont, meaning if you return false at any level, stop the recursive calls and return false. If you return true, remove the first and last characters of the string and pass the address of the shortened string in $a0. Treat the original string as immutable, much as Java does. (How does Java deal with this?)
3. You must have two files. The first has the main body of your code that requests a string, calls a function that checks a palindrome, which is item 2, above plus initialization code. The second file has any subroutines you may need, such as removing punctuation and converting case.
This structure is part of the requirements and something you need to learn.
Recursion is also part of this. Consider how you pass a string as an argument such that each level gets a new string on the stack.
Is a string of length 0 or length 1 a palindrome? This is your base case.
I suggest you return the Boolean result as 1 for true and zero for false in $v0.
You will need to check the Assemble all files in directory setting for this to work.
Your program will be tested with a string that contains no letters and no digits.
To hand in through eLearning: A Zip file named CS2340-Asg4-.zip where you replace with your netID. For example, if I were to hand it in, the name would be CS2340-Asg4-jxc064000.zip. This must contain ALL files necessary to assemble and run your program.
Grading Criteria
Comments and variable names
15
Recognizes correct palindromes and rejects things that are not
35
Correct program structure
40
Does not crash
10
Total
100
Additional grading criteria:
Errors in detecting and recognizing correct and incorrect palindromes: -5 to -35, depending upon severity.
Crashes for any reason: -10 or more
Only one file: -25
Poor code formatting: -2 to -10
Poor coding practices, such as spaghetti code, use of magic numbers, etc. -2 to -10
Using .include for your secondary file. -25
Code structure such as calls not nested, not using the stack, not using it correctly, in-line code for the palindrome, etc. -5 to -35
Exits after every test. -5
Does not exit when I press enter. -5
Not recursive. -35 or more, depending upon severity.
Zip file does not contain your NetID. -5
Missing header comments or other documentation problems: -2 to -15.
Does not assemble. -70 or more, depending upon severity.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!