Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 71b1ef8

Browse filesBrowse files
authored
Create SnakeCase.java
1 parent fefbaf5 commit 71b1ef8
Copy full SHA for 71b1ef8

File tree

Expand file treeCollapse file tree

1 file changed

+34
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+34
-0
lines changed

‎Easy/SnakeCase.java

Copy file name to clipboard
+34Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Main {
5+
6+
public static String SnakeCase(String str) {
7+
// code goes here
8+
9+
String result="";
10+
11+
for (int i =0 ; i<str.length() ; i++){
12+
13+
if(Character.isAlphabetic(str.charAt(i))){
14+
result+=str.charAt(i);
15+
16+
}else{
17+
18+
result+="_";
19+
}
20+
21+
22+
}
23+
24+
result=result.toLowerCase();
25+
return result;
26+
}
27+
28+
public static void main (String[] args) {
29+
// keep this function call here
30+
Scanner s = new Scanner(System.in);
31+
System.out.print(SnakeCase(s.nextLine()));
32+
}
33+
34+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.