-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab2_3.java
More file actions
53 lines (43 loc) · 1.3 KB
/
Lab2_3.java
File metadata and controls
53 lines (43 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.util.Scanner;
public class Lab2_3 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String min = " ";
String mid = " ";
String max = " ";
System.out.print("Enter the first city:");
String first = input.nextLine();
System.out.print("Enter the second city:");
String second = input.nextLine();
System.out.print("Enter the third city:");
String third = input.nextLine();
char a = first.charAt(0);
char b = second.charAt(0);
char c = third.charAt(0);
if (a<b && a<c)
min=first;
else if (a>b && a>c)
max=first;
else if (a>b && a<c)
mid=first;
else if (a<b && a>c)
mid=first;
if (b<c && b<a)
min = second;
else if (b>c && b>a)
max = second;
else if (b>c && b<a)
mid = second;
else if (b<c && b>a)
mid = second;
if (c<a && c<b)
min = third;
else if (c>a && c>b)
max = third;
else if (c>a && c<b)
mid = third;
else if (c<a && c>b)
mid = third;
System.out.println("The tree cities in alphabetical order are "+min+" "+mid+" "+max);
}
}