Question: rogram #3: Write a Java program that works with Java's String class. The program will perform the following tasks: - Allow the user to input

rogram \#3: Write a Java program that works with Java's String class. The program will perform the following tasks: - Allow the user to input two strings from the keyboard: - Use nextLine 0 in case the user inputs strings containing spaces. - After both strings have been input, print them back out. - Print back the longer string: If the two strings have the same length, print "Same length" instead. - Print out the first character of the first string followed by the last character of the second string. - Print the two strings out in lexicographical order: If the two strings are the same, just print one of them. A run of the program should look similar to the following: \( \left[\begin{array}{l}\text { - -jGRASP exec: java Program_3_Jerkofsky } \\ \text { Input String \#1: abcde } \\ \text { Input String \#2: fghi } \\ \text { Strings input: } \\ \text { String \#1: abcde } \\ \text { String \#2: fghi } \\ \text { Longer string: abcde } \\ \text { First and last characters: ai } \\ \text { Strings in lexicographical order: } \\ \text { abcde fghi } \\ \text { - jGRASP: operation complete. }\end{array} ight. \)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
