I need help with this coding assignment I have.
Assignment:
¨User will input two words
The longer word will output in reverse starting with the last letter until the middle letter
The shorter word will output in order starting at the middle until the end; then output at the beginning until (but not including) the middle
-in the scenario of same length, the shorter word will be designated with the first input
Example
"radio" and "computer" should produce
"radio" would be "diora"
"computer" would be "retu"¨
^thats the assignment.
the thing I'm trying to figure is what exactly to put in the if and else statements.
my code:
System.out.println("Input word #1: ");
String w1 = scan.nextLine();
System.out.println("Input word #2: ");
String w2 = scan.nextLine();
int len1 = w1.length();
int len2 = w2.length();
int location1 = w1.indexOf( w1 );
int half1 = len1/ 2;
int location2 = w2.indexOf( w2 );
int half2 = len2/ 2;
if(len1 > len2){
System.out.println(len1);
}
else{
}
Please help me.