0
What's Wrong? Why?
import java.util.*; class VowelConsonant { public static void main(String args[]) { Scanner input=new Scanner(System.in); System.out.print("Enter Any Letter : "); char ch; ch= input.next().CharAt(0); if(ch=='A' || ch=='a' || ch=='E' || ch=='e' || ch=='I' || ch=='i' || ch=='O' || ch=='o' || ch=='U' || ch=='u'){ System.out.println(ch+" Is a Vowel"); }else{ System.out.println(ch+" Is a Consonant"); } } }
4 Respuestas
+ 3
Yup that question totally make sense...
Next time, try to be more constructive on your question. Ask a specifically and state an exact problem you have, rather than just writing "What's wrong"
Regarding your question, you wrote CharAt() instead of charAt()
Here is a fixed version of your code:
https://code.sololearn.com/cy8C0qx08Ama/?ref=app
+ 5
// this is another way that you could do it.
Scanner input=new Scanner(System.in);
char ch= input.next().CharAt(0);
String v= "aeiou";
if (v.indexOf(Character.toLowerCase(ch))>=0)
System.out.println(ch+" Is a Vowel");
else
System.out.println(ch+" Is a Consonant");
+ 1
Okay😶
Thanks
+ 1
Milon , No problem buddy 👍
Happy learning!