Computers and Technology
Computers and Technology, 03.12.2019 01:31, Chloe1414

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.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 23:30, Molly666
What does 21 pilots middle aged name as a band 15 years prior to them naming their band 21 pilots?
Answers: 1
image
Computers and Technology, 23.06.2019 02:30, paolaviviana
Experimental data that is expressed using numbers is said to be
Answers: 1
image
Computers and Technology, 23.06.2019 13:30, juliajordan427
Best laptops for college [$100-$500 range]?
Answers: 2
image
Computers and Technology, 23.06.2019 14:00, allison9746
Need ! will choose brainliest! discuss the role of abstraction in the history of computer software.
Answers: 1
Do you know the correct answer?
Test palindrome

a string like "radar", "racecar", and "abba"that reads the same in eith...

Questions in other subjects:

Konu
Business, 27.07.2019 03:30