subject

Test palindrome

a string like "radar", "racecar", and "abba"that reads the same in either direction. to enable longer palindromes, we can ignore spaces, punctuation, and the cases of the letters. for example:

"a man, a plan, a canal, panama! "
is a palindrome, because if we ignore spaces and punctuation and convert everything to lowercase we get

"amanaplanacanalpanama"
which is a palindrome.

in the file palindrome. java add a static method called ispal() that takes a string object as a parameter and determines if it is a palindrome, returning true if it is and false if it is not.

a string of length 1 and an empty string should both be considered palindromes. throw an exception for null values.

although we can implement solutions to this problem using recursion or an appropriately constructed loop that manipulates the string object directly, your method must use an instance of one of the following collection classes from arrayqueue

you must not use any other data structure, including arrays or linked lists other than the ones that are "inside" instances of the above collections. rather, you should put individual characters from the original string into an instance of one or more of the above collections, and use those collection object(s) to determine if the string is a palindrome.

for full credit, you should:

write your method so that spaces, punctuation, and the cases of the letters don’t prevent a string from being a palindrome. to put it another way, make sure that your method only considers characters in the string that are letters of the alphabet and that it ignores the cases of the letters. see our example above.

make your method as efficient as possible. in particular:

you should perform only one iteration over the original string object. after that one iteration, any additional manipulations of the characters should be done using the collection object(s) that you have chosen to use.

because we want to avoid unnecessary scanning, you may not use any of the built-in string methods except charat() and

hints:

when constructing the collection object(s) that you decide to use, you will need to specify the appropriate data type for the items in the collection. because char values are primitives, you should use the corresponding "wrapper" class, which is called character.

you may also find it to use the character. tolowercase() or character. touppercase() method.

remember that char values are essentially integers, so you can compare them just as you would compare integers.

(5 points) for professional programmers, writing well-formatted units tests is an extremely important part of their work. in the main() method of palindrome. java, we’ve given you an example of what such a unit test should look like.

add five additional unit tests for your ispal() method to the main() method. your unit tests must follow the same format as our example test. in particular, the output of each of your unit tests should include:

a header that specifies the test number and a description of what is being tested
the actual return value that you get from that test
the expected return value
whether the actual return value matches the expected return value.
put each test in the context of a try-catch block so that you can handle any exceptions that are thrown. leave a blank line between tests.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
The editing of digital photos us about the same level of difficulty as editing an analog photo
Answers: 2
question
Computers and Technology, 23.06.2019 06:30
Martha is designing a single-player game. her manager suggests that she plan the design to incorporate future modifications. which principle of game design relates to planning for future modifications?
Answers: 1
question
Computers and Technology, 24.06.2019 00:30
Use the keyword strategy to remember the meaning of the following word. the meaning for the word has been provided. write your keyword and describe the picture you would create in your mind. obfuscate: to make something so confusing that it is difficult to understand.
Answers: 2
question
Computers and Technology, 24.06.2019 10:30
This device directs network traffic. bridge hub nic repeater router switch
Answers: 3
You know the right answer?
Test palindrome

a string like "radar", "racecar", and "abba"that reads the same in eith...
Questions
question
Mathematics, 07.05.2020 12:57