-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathCamelCase.java
More file actions
56 lines (42 loc) · 1.09 KB
/
CamelCase.java
File metadata and controls
56 lines (42 loc) · 1.09 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class CamelCase {
// Complete the camelcase function below.
static int camelcase(String s) {
if(s.length() == 0 || s == null){
return 0;
}
int counter = 0;
for(int j=0;j<s.length();j++){
if(Character.isUpperCase(s.charAt(j))){
counter++;
}
}
if(counter == 0){
return 1;
}else{
counter = 0;
}
int i=0;
while(!Character.isUpperCase(s.charAt(i))){
i++;
}
counter++;
for(int j=i;j<s.length();j++){
if(Character.isUpperCase(s.charAt(j))){
counter++;
}
}
return counter;
}
public static void main(String[] args) throws IOException {
Scanner input = new Scanner(System.in);
String s = input.nextLine();
System.out.println(camelcase(s));
}
}