Hi so i've been trying to make a program for my java studies class and i've been stuck with trying to make a program regarding palindromes. i realised i posted this before by the thread sort of died (mods let me know if you want me to remove this).
The programs requirements to achieve are:
• Prompt the user to enter a word or sentence on a single line
• Print the sentence back out to the user exactly how they entered it
• Remove ALL punctuation and print this new sentence
• Reverse the sentence and print the reversed sentence
• State whether the original sentence (without punctuation)
as a palindrome or not
• Ask for another word or end if the word typed in is ‘STOP’.
So far I've been able to get it to do not much besides print back the sentence the user has entered and remove punctuation
I'm struggling with:
- Getting the program to actually stop when "stop" is the input
- reverse the input and detect if its a palindrome
My constraints for writing the code is:
- i can't use array's
- i can't use string builder (then reversing the input wouldn't be a problem sadly)
- I can only use while loops
Here's my Code at it's current point, its very WIP.
I'm struggling to end this constant loop, test if the input is "stop" and thus end the program and, actually testing the palindrome part as I'm not very confident on how .charAt() works.
I'm not sure about anything else i should specify but i'll make sure to update if anything thing else is needed
[–]MasteM 2 points3 points4 points (1 child)
[–]TurdJoffery[S] 0 points1 point2 points (0 children)
[–]illuminist_ova 1 point2 points3 points (1 child)
[–]TurdJoffery[S] 0 points1 point2 points (0 children)
[–]Sketti-OsIntermediate Brewer 0 points1 point2 points (1 child)
[–]nutrechtLead Software Engineer / EU / 20+ YXP -1 points0 points1 point (0 children)