-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp8.java
More file actions
37 lines (35 loc) · 1.19 KB
/
p8.java
File metadata and controls
37 lines (35 loc) · 1.19 KB
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
31
32
33
34
35
36
37
/**
* Create a class which ask the user to enter a sentence, and it should display count of each vowel type
in the sentence. The program should continue till user enters a word “quit”. Display the total count
of each vowel for all sentences
*/
import java.util.Scanner;
public class p8 {
public static void main(String args[]) {
Scanner s1 = new Scanner(System.in);
String str;
int a, e, i, o, u;
while(true) {
a = 0;
e = 0;
i = 0;
o = 0;
u = 0;
System.out.println("Enter string or type quit : ");
str = s1.nextLine();
if(str.toLowerCase().equals("quit"))
break;
for(int i_ = 0; i_ < str.length(); i_++)
{
switch(str.toLowerCase().charAt(i_)) {
case 'a' : a++; break;
case 'e' : e++; break;
case 'i' : i++; break;
case 'o' : o++; break;
case 'u' : u++; break;
}
}
System.out.println("a : " + a + "\ne : " + e + "\ni : " + i + "\no : " + o + "\nu : " + u);
}
}
}