You don't need a for loop in your code.
Here is how you can re implement your method
- If input is between 'A' and 'Z' its uppercase
- If input is between 'a' and 'z' its lowercase
- If input is one of 'a,e,i,o,u,A,E,I,O,U' its Vowel
- Else Consonant
Edit:
Here is hint for you to proceed, Following code snippet gives int
values for char
s
System.out.println("a="+(int)'a');
System.out.println("z="+(int)'z');
System.out.println("A="+(int)'A');
System.out.println("Z="+(int)'Z');
Output
a=97
z=122
A=65
Z=90
Here is how you can check if a number x
exists between two numbers say a
and b
// x greater than or equal to a and x less than or equal to b
if ( x >= a && x <= b )
During comparisons char
s can be treated as numbers
If you can combine these hints, you should be able to find what you want ;)