Skip to content

Commit

Permalink
lexigraphic.java created
Browse files Browse the repository at this point in the history
  • Loading branch information
Ardusa committed Nov 17, 2023
1 parent eb4cc1a commit e5c232b
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions lexigraphic.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import java.util.Scanner;

public class lexigraphic {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);

System.out.print("Enter word 1: ");
String s1 = in.next();

System.out.print("Enter word 2: ");
String s2 = in.next();

System.out.print("Enter word 3: ");
String s3 = in.next();

if (s1.compareTo(s2) < 0 && s1.compareTo(s3) < 0) {
if (s2.compareTo(s3) < 0) {
System.out.println(s1 + " " + s2 + " " + s3);
} else {
System.out.println(s1 + " " + s3 + " " + s2);
}
} else if (s2.compareTo(s1) < 0 && s2.compareTo(s3) < 0) {
if (s1.compareTo(s3) < 0) {
System.out.println(s2 + " " + s1 + " " + s3);
} else {
System.out.println(s2 + " " + s3 + " " + s1);
}
} else {
if (s1.compareTo(s2) < 0) {
System.out.println(s3 + " " + s1 + " " + s2);
} else {
System.out.println(s3 + " " + s2 + " " + s1);
}
}
in.close();
}
}

0 comments on commit e5c232b

Please sign in to comment.