Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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: price
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started