As I said, how to check if the entered character is one of the parameters? I wrote this code, but it doesn't seem to work very well (or at all), but no errors. In addition, I need to use the base code that I used here. This is for school, and we lose points if we use something that we have not been taught (darn school).
class doody { public static void main(String[] args) { char i; char input='D'; for(i='A';i<='Z';i++)//check if uppercase { if(input==i){ System.out.println("Uppercase"); switch(input){ case 'A': case 'E': case 'I': case 'O': case 'U': System.out.println("Vowel"); break; default: System.out.println("Not a vowel"); break;} } for(i='a';i<='z';i++)//check if lowercase { if(input==i){ System.out.println("Lowercase"); switch(input){ case 'a': case 'e': case 'i': case 'o': case 'u': System.out.println("Vowel"); break; default: System.out.println("Not a vowel"); break; }} for(i='0';i<='9';i++)//check if number { if(input==i) System.out.println("Number"); } } }}}
Edit: Here is the code I compiled today. Much easier. I do not know why this has not happened before. Probably because I was awkward, it was too late.
class doody { public static void main(String[] args) { char input='$';//input here. boolean lorn=false; if(input>='a'&&input<='z') {System.out.println("Lowercase"); lorn=true; if(input=='a')System.out.println("Vowel."); if(input=='e')System.out.println("Vowel."); if(input=='i')System.out.println("Vowel."); if(input=='o')System.out.println("Vowel."); if(input=='u')System.out.println("Vowel."); } if(input>='A'&&input<='Z') {System.out.println("Uppercase"); lorn=true; if(input=='A')System.out.println("Vowel."); if(input=='E')System.out.println("Vowel."); if(input=='I')System.out.println("Vowel."); if(input=='O')System.out.println("Vowel."); if(input=='U')System.out.println("Vowel."); } if(input>='0'&&input<='9') { lorn=true; System.out.println("Number"); } if(lorn==false)System.out.println("It is a special character"); } }
Prnth source share