(1) Ask the user to type in a sentence or phrase with between 2 and 5 words (2 really would be fine).
(2) Display the user’s sentence or phrase.
(3) Reverse the wording by word.
(4) Reverse the entire sentence by characters.
(5) Find a substring in the sentence or phrase and display it. (It need not be an actual word)
(6) Display only the first word of the user’s sentence or phrase all in upper case letters.
(7) Display the length of the original sentence or phrase.
So far..
System.out.print("Hello user, please enter a sentence or phrase which is two words:");
String s1, s2;
s1 = keyboard.next();
s2 =keyboard.next();
System.out.println("You entered\"" + s1 + "\" and \"" + s2 + "\"");
if(s1.equals(s2));
So I got the program to separate the two strings. I am on step 3 now and I am wondering if i need to equal both the strings in order to continue. I tried up there but i dont think it is right. For example if the user puts : " Hello World" it would be "World Hello." I need help. I know how to reverse the letters of each string but how can i do that to both words. I tried this but it did not work for s2 only s1 which it said olleH:
String str[]=s1.split("");
s2.split("");
String reversedSt="";
for(int i=str.length-1;i>=0;i--){
reversedSt+=str[i];
Please help. I have until wednesday! Thank you!