-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIfVowels.java
More file actions
60 lines (54 loc) · 1.57 KB
/
Copy pathIfVowels.java
File metadata and controls
60 lines (54 loc) · 1.57 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
54
55
56
57
58
59
60
/**
* IfVowels.java
* Demo comparing three chars for the highest value
*/
import java.util.Scanner;
public class IfVowels
{
// Compares each vowel in a string.
public static void main (String[] args)
{
Scanner keyboard = new Scanner(System.in);
char high, med, low;
System.out.println ("Enter a string of 3 characters - watch for case differences :");
String str = keyboard.nextLine();
if ( str.charAt(0) > str.charAt(1) )
if (str.charAt(0) > str.charAt(2) )
{ high = str.charAt(0);
if (str.charAt(1) > str.charAt(2) )
{ med = str.charAt(1);
low = str.charAt(2);
}
else
{ med = str.charAt(2);
low = str.charAt(1);
}
}
else
{ high = str.charAt(2);
med = str.charAt(0);
low = str.charAt(1);
}
else
if (str.charAt(1) > str.charAt(2) )
{ high = str.charAt(1);
if (str.charAt(0) > str.charAt(2) )
{ med = str.charAt(0);
low = str.charAt(2);
}
else
{ med = str.charAt(2);
low = str.charAt(0);
}
}
else
{ high = str.charAt(2);
med = str.charAt(1);
low = str.charAt(0);
}
System.out.print ("The numbers in order from low to high are: ");
System.out.print (low + " ");
System.out.print (med + " ");
System.out.println (high );
}
}