Question: What is incorrect about my code? Please keep it simple like I have it here. * Accept a string such as varTwo = 5 -

What is incorrect about my code? Please keep it simple like I have it here.

* Accept a string such as "varTwo = 5 - theBestVar"
* Convert the string to a line in which the camel case substrings are
converted to snake style substrings.
* display the string
* please name your java source file as CamelToSnake.java
*
* Note: if there are multiple Uppercase letters, then split the
* string so that the last capital character is part of the
* next word. For example WCURams would become wcu_rams
*
* For example:
* Example 1:
* input: varTwo = 5 - theBestVar
* output: var_two = 5 - the_best_var
* Example 2:
* input: CMMaxLength = INMaxLength / 2.54
* output: cm_max_length = in_max_length
public class CamelToSnake {
String lowerstring = "";
char A = str.charAt(0);
lowerstring = lowerstring + Character.toLowerCase(a);
for (int i=1; i
char ch = str.charAt(i);

if(Character.isUpperCase(ch)) {

lowerstring = lowerstring + Charcter.toLowerCase(ch);
}
else {
lowerstring = lowerstring + ch;
}
}
return lowerstring;
}
public static void main(String[] args) {
// program starts running here.
}
System.out.println(CamelToSnake(string));
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!