-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.java
More file actions
31 lines (29 loc) · 910 Bytes
/
string.java
File metadata and controls
31 lines (29 loc) · 910 Bytes
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
public class string {
public static String uppercase(String str){
String newstr="";
newstr += Character.toUpperCase(str.charAt(0));
for(int i=1;i<str.length();i++){
if(str.charAt(i)==' '&& i<str.length()-1){
newstr += str.charAt(i);
i++;
newstr += Character.toUpperCase(str.charAt(i));
}
else
newstr += str.charAt(i);
}
return newstr;
}
public static int countVowels(String str){
int count=0;
for(int i=0;i<str.length();i++){
if (str.charAt(i)=='a'||str.charAt(i)=='e'||str.charAt(i)=='i'||str.charAt(i)=='o'||str.charAt(i)=='u'){
count++;
}
}
return count;
}
public static void main(String[] args) {
String str="hedytaeiou";
System.out.println(countVowels(str));
}
}