forked from MLSA-MUET-SZAB-Club-Khairpur-Mir-s/Learn-to-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCountVowels.java
30 lines (28 loc) · 892 Bytes
/
CountVowels.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.Scanner;
class Vowels {
String name;
public void Input() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the name");
name = sc.nextLine();
}
public void Find_vowels()
{
int counter = 0;
for(int i=0; i<name.length(); i++)
{
if(name.charAt(i)=='A'||name.charAt(i)=='E'||name.charAt(i)=='I' || name.charAt(i)=='O'|| name.charAt(i)=='U' || name.charAt(i)=='a'||name.charAt(i)=='e'||name.charAt(i)=='i' || name.charAt(i)=='o'|| name.charAt(i)=='u')
{
counter++;
}
}
System.out.println("In name there are "+counter+" vowels" );
}
}
public class CountVowels {
public static void main(String[] args) {
Vowels v1 = new Vowels();
v1.Input();
v1.Find_vowels();
}
}