Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using the scanner class, read in three strings as input. Using the compareTo() method of the String class as well as decisions, decide which string
Using the scanner class, read in three strings as input. Using the compareTo() method of the String class as well as decisions, decide which string would come lexicographically (alphabetically) first.
In java please!
Using the scanner class, read in three strings as input. Using the compareTo() method of the String class as well as decisions, decide which string would come lexicographically (alphabetically) first. INPUT Three Strings: - String a - String b - String c PROCESSING The compareTo() method of the String class compares two strings and returns a positive or negative value depending on which String is lexicographically first. If the two Strings are equal, then 0 is returned. "A".compareTo("B") will return 1, since " A " is one letter before " B " "C".compareTo("A") will return +2 since " C " is two letters after " A " "Ice cream".compareTo("Ice cream") will return 0 , since they are lexographically the same *Note: For this question you do not have to implement a test for two strings being lexicographically the same. You are guaranteed the input strings will be unique. Remember that order of comparison matters for your result. OUTPUT whatever string is first lexicographically
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