Java vs. C++
ID: 1170
Description
Apologists of Java and C++ can argue for hours with each other over which programming language is the best one. Java people will say their programs are clearer and less prone to errors, while C++ people will laugh at the inability to instantiate an array of generics in Java or say that Java programs have a large number of lines of code are slow.

Another issue that Java and C++ people can never agree on is how to write identifiers. In Java a multipart identifier is constructed in the following manner: the first part is written starting with a small letter, and the following ones are written starting with a capital letter, no separators are used. All other letters are small. Parts must have a least one letter in them. Examples of a Java identifier are "javaIdentifier", "longAndMnemonicIdentifier", "name", "nEERC". This convention is sometimes known as lowerCamelCase.

On the other hand, C++ people use only small letters in their identifiers. To separate parts (parts must have a least one letter) they use underscore character '_'. Examples of C++ identifiers are "c_identifier", "long_and_mnemonic_identifier", "name" and "n_e_e_r_c". When there is just one part in the identifier, Java and C++ people agree on how to write it.

You are to write a translator that translates C++ identifiers to Java and vice versa. Given an identifier, the program should detect whether it is Java identifier or C++ identifier and translate it to the other dialect. If it is neither, then your routine should report an error. Translation must preserve the order of parts and must only change the case of letters and/or add/remove underscores.
Input
The input consists of a single line. The line consists of a single identifier composed of letters of the alphabet [a-zA-Z] and underscores. Its length does not exceed 100.
Output
If the input identifier is Java identifier, output its C++ version. If it is C++ identifier, output its Java version. If it is neither, output "Error!" instead.
Sample Test Cases
InputExpected Output
long_and_mnemonic_identifier
longAndMnemonicIdentifier
anotherExample
another_example
i
i
bad_Style
Error!
Statistics
The Tops
Shortest Submission eddie-w (msu) 0.35 kB Ruby 1.8.6 view
Most Popular Submission eddie-w (msu) 2.51 Ruby 1.8.6 view