In this chapter, we learn about using strings and string conversions in our codi
ID: 644130 • Letter: I
Question
In this chapter, we learn about using strings and string conversions in our coding. Obviously as you know, using and manipulating strings in any kind of code, whether it be command line coding or full on object oriented programming is a definite task. Since this is midterm week, we will be doing something simple as far as programming with some extra credit possibility. For this assignment, your program needs to ask the user to input a string or a sentence. When the user presses enter, the program will display the same sentence spelled backwards. That is all we really need to do. Now, for the extra credit. To get 5 points extra credit, do the above programming. At the end of your program though, program a check in the code to check to see if the sentence is a palindrome. This means that when you take the sentence and reverse it, it will spell the same thing. Tell me if the sentence is a palindrome or not. If you can successfully tell me that, I will give you 5 points extra credit. Since extra credit is just that
Explanation / Answer
public static void main(String[] args) { StringReverse sr =new StringReverse(); String output=sr.reverse("reverse this string"); String substring=""; for(int i=0;i 1; j >= 0; --j) { char temp = value[j]; value[j] = value[n - j]; value[n - j] = temp; } return new String(value); if(sr.reverse()=sr){ System.out.println("Paindorme"); } else{ System.out.println("Not palindrome"); } } }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.