Question: Given string strInput1 on one line and string strInput2 on a second line, assign longerString with the longer string. If the strings are the same

Given string strInput1 on one line and string strInput2 on a second line, assign longerString with the longer string. If the strings are the same length, assign longerString with "Same length". Ex: If the input is: ice price then the output is: priceGiven string strInput1 on one line and string strInput2 on a second

Given string strInput1 on one line and string strinput2 on a second line, assign longerString with the longer string. If the strings are the same length, assign longerString with "Same length". Ex: If the input is: ice price then the output is: price \begin{tabular}{l|l} 1 & import java.util. Scanner; \\ 2 & \\ 3 & public class stringCompare \{ \\ 4 & public static void main(String[] args) \{ \\ 5 & Scanner scnr = new Scanner(System.in); \\ 6 & String strInput1; \\ 7 & String strInput2; \\ 8 & String longerstring; \\ 9 & \\ 10 & strInput1 = scnr.nextLine(); \\ 11 & strInput2 = scnr.nextLine(); \\ 12 & \\ 13 & /* Your code goes here / \\ 14 & \\ 15 & System.out.println(longerstring); \\ 16 & \} \\ 17 & \end{tabular}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!