Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program using eclipse that asks the user to input two Strings, each in a

ID: 3649376 • Letter: W

Question

Write a program using eclipse that asks the user to input two Strings, each in a separate JOptionPane. Your program should print out the String that is first in lexicographic (dictionary) order.

This should be a 2-class program. One class should be a "Min" class, which is very similar to the Example below Max class. The other class should be a simple driver class that asks the user to enter two strings, calls the method of the Min class to find the minimum (first in order), and prints it out.
Process Description

Write the code for the Min class, using the Max class example.
Create the driver class for this program, call it "MinTest".

Make sure that your MinTest method imports the Swing classes, that it asks the user to enter two separate strings, and that it prints out the first (minimum) string.

Breakpoints

Breakpoints are debugger functions that suspend execution of the program. If you put a breakpoint on a line of code, the program stops executing at that line of code, and you can see portions of the state of the system. By using breakpoints, you can halt execution of the system and examine what is going on with your program without having to write a bunch of System.out.println(...) statements and recompiling/rerunning the program.

do simple breakpointing.

Go to the Min class. Define a breakpint as follows:
To the left of the code you see a blue bar. Put your cursor on this bar, next to the method signature line in your Min code.
Right-click on the bar, and select "Toggle breakpoint". A filled blue circle will appear. This means that you have an active breakpoint at this location. Note: It's really hard to see the filled blue circle. But that won't matter for a while.
Run your application again, this time in Debug mode. This will allow breakpoints to "fire".
Select Run

Explanation / Answer

public class StringCompare 02 { 03 public static void main( String args[] ) 04 { 05 System.out.println( "Is the first String less than, equal to or greater than the second " ); 06 String s1 = new String( "Enter first string" ); // Request first value from user 07 String s2 = new String( "Enter second string" ); // Request next value from user 08 09 System.out.printf( "s1 == s is " + (s1 == s2)); 10 System.out.println( "s1.equals(s2) is " + (s1.equals(s2))); 11 12 13 14 // test for equality 15 if ( s1.equals( s2 )) // true 16 System.out.println( "string1 and string2 are equal" ); 17 else 18 System.out.println( "string1 and string2 are not equal" ); 19 20 // test for equality with == 21 if ( s1 == ( s2 )) // false; s1 is not equal to s2 22 System.out.println( "string1 and string2 are equal" ); 23 else 24 System.out.println( "string1 and string2 are not equal" ); 25 26 27 // test compareTo 28 System.out.printf( 29 " s1.compareTo( s2 ) is %d", s1.compareTo( s2 )); 30 System.out.printf( 31 " s2.compareTo( s1 ) is %d", s2.compareTo( s1 )); 32 System.out.printf( 33 " s1.compareTo( s1 ) is %d ", s1.compareTo( s1 )); 34 35 } // end main 36 } // end class StringCompare

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote