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

Write a program that reads in three strings and sorts them lexicographically. Sh

ID: 3651651 • Letter: W

Question

Write a program that reads in three strings and sorts them lexicographically. Show at least three testing results of your program. example:

Enter three strings: Charlie Able Baker
Able
Baker
Charlie

Explanation / Answer

import java.util.Scanner; public class asi3 { public static void main(String[] args) { String name1, name2, name3 ; boolean b, b1; int i, i1, i2,i3; Scanner keyboard = new Scanner(System.in); System.out.println("please enter three names: "); name1=keyboard.nextLine(); name2=keyboard.nextLine(); name3=keyboard.nextLine(); b = name1.equals(name2); // Check if identical ignoring case b1 = name1.equalsIgnoreCase(name2); i = name1.compareTo(name2); if (i < 0) { i1 = name1.compareToIgnoreCase(name3); if (i1 < 0) { System.out.println(name1); if (i1 > 0) { System.out.println(name3); i2 = name2.compareToIgnoreCase(name3); if (i20) { System.out.println(name3); System.out.println(name2); } } } } else if (i > 0) { i1 = name2.compareToIgnoreCase(name3); if (i1 < 0) { System.out.println(name2); if (i1 > 0) { i2 = name1.compareToIgnoreCase(name3); if (i20) { System.out.println(name3); System.out.println(name1); } } } } } }
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