+ 6
Vowel And Consonant Detector First And Last letter
hi i have this code that can only tell if the inputted character is vowel or consonant https://code.sololearn.com/c3vL3ctTbFgt/?ref=app but i want to detect the start and ending letter of a word, if it is both vowel, both consonant, or Mix V&C, inputed by the user to a textbox. Example1: Input : Avocado Output : Both Vowel Example2: input: Kahapon Ouput: Both Consonant Can someone edit it through my code for my reference? Thank you so much! â€ïžâ€ïž
7 Respostas
+ 6
I have done for example 1. You can implement it in other ways as well.
https://code.sololearn.com/cilR0Z81XK3G/?ref=app
+ 6
You can also refer this if you want :) đ
https://code.sololearn.com/cmPQ2JEoak4R/?ref=app
+ 5
You can use also use startsWith() and ends with() method.
if(str.startsWith("a") && str.endsWith("o")){
System.out.println("both Vowel");
}
+ 4
Yeah, if she wants to do it by writing all combinations of vowels in condition, btw forloops can done this without having to write all those combinations(only if I want to use startsWith() and endsWith() method). But it's unnecessarily complicated, compared to your best solution for this problem.
String str=input.toLowerCase();
String vowels[]={//aeiou};
boolean b=false;
for (int x=0;x <= vowels.length - 1;x++)
{
if (str.startsWith(vowels[x]))
{
for (int y=0;y <= vowels.length - 1;y++)
{
if (str.endsWith(vowels[y]))
{
b = true;
}
}
}
}
if (b)
System.out.print("yes");
else
System.out.print("no");
+ 4
0_O-[MĂ€gĂĄr_SĂĄm_ĂkĂ _NĂŒllpÞïntĂȘr_ĂxĂ«cĂ©ptïön]~~ there could be multiple approaches to this problem. I gave mine and you gave yours. As long as she is in the learning phase, she can use any approach and get the result.
+ 2
0_O-[MĂ€gĂĄr_SĂĄm_ĂkĂ _NĂŒllpÞïntĂȘr_ĂxĂ«cĂ©ptïön]~~ In this way she might have to write for all combinations of the vowels, isn't it? How does one know that what is the input going to be.
- 4
Hi