-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathCamelCase.java
More file actions
36 lines (25 loc) · 861 Bytes
/
Copy pathCamelCase.java
File metadata and controls
36 lines (25 loc) · 861 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
32
33
34
35
36
import java.util.*;
import java.io.*;
class Main {
public static String StringChallenge(String str) {
// code goes here
str = str.toLowerCase();
char[] charArray = str.toCharArray();
for(int i = 0; i < charArray.length; i++) {
if(!(charArray[i] <= 90 && charArray[i] >= 65 || charArray[i] <= 122 && charArray[i] >= 97)) {
charArray[i] = ' ';
if(charArray[i] == ' ' && charArray[i+1] <= 122 && charArray[i+1] >= 97){
charArray[i+1] -= 32;
}
}
}
String str2 = String.copyValueOf(charArray);
str2 = str2.replaceAll("\s", "");
return str2;
}
public static void main (String[] args) {
// keep this function call here
Scanner s = new Scanner(System.in);
System.out.print(StringChallenge(s.nextLine()));
}
}