+ 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! ❀❀

5th Nov 2020, 8:42 AM
Lia Costa ✹
Lia Costa ✹ - avatar
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
5th Nov 2020, 9:04 AM
Avinesh
Avinesh - avatar
+ 6
You can also refer this if you want :) 👇 https://code.sololearn.com/cmPQ2JEoak4R/?ref=app
5th Nov 2020, 11:18 AM
Minho
Minho - avatar
+ 5
You can use also use startsWith() and ends with() method. if(str.startsWith("a") && str.endsWith("o")){ System.out.println("both Vowel"); }
5th Nov 2020, 9:06 AM
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~ - avatar
+ 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");
5th Nov 2020, 10:01 AM
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~
0_O-[MĂ€gĂĄr_SĂĄm_ÄkĂ _NĂŒllpÞïntĂȘr_ÈxĂ«cĂ©ptïön]~~ - avatar
+ 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.
5th Nov 2020, 10:14 AM
Avinesh
Avinesh - avatar
+ 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.
5th Nov 2020, 9:08 AM
Avinesh
Avinesh - avatar
- 4
Hi
6th Nov 2020, 3:32 PM
Alaa Bashir
Alaa Bashir - avatar