Advertisement
Guest User

Sort Strings Lexi

a guest
Jan 28th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. import java.util.*;
  2. /**
  3. * Write a description of class tes here.
  4. *
  5. * @author (your name)
  6. * @version (a version number or a date)
  7. */
  8. public class tes
  9. {
  10. // instance variables - replace the example below with your own
  11. public static void main(String[] args)
  12. {
  13. Scanner keyboard = new Scanner(System.in);
  14. System.out.println("hello enter first sentence");
  15. String f = keyboard.nextLine();
  16. System.out.println("hello enter second sentensce");
  17. String s = keyboard.nextLine();
  18. System.out.println("hello enter third sentensce");
  19. String l = keyboard.nextLine();
  20. //note that f stands for first, s for second, and l for last
  21. if(f.compareTo(s) > 0 && f.compareTo(l) < 0)
  22. System.out.println(f + " First sentence case 1");
  23. else if(f.compareTo(l) > 0 && f.compareTo(s) < 0)
  24. System.out.println(f + " First sentence case 2");
  25. else if (s.compareTo(f) > 0 && s.compareTo(l) < 0)
  26. System.out.print(s + " Second sentence case 1");
  27. else if (s.compareTo(l) > 0 && s.compareTo(f) < 0)
  28. System.out.print(s + " Second sentence case 2");
  29. else if (l.compareTo(s) > 0 && l.compareTo(f) < 0)
  30. System.out.println(l + " third sentence case 1");
  31. else if (l.compareTo(f) > 0 && l.compareTo(s) < 0)
  32. System.out.println(l + " third sentence case 2");
  33. //System.out.println(f.compareTo(s));
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement