Thursday, 10 October 2013

Infosys aspration 2020 2013 college round question-4

// siddhu vydyabhushana // 11 comments
aspiration-2020 translator


In a country of Neverland there are two types of programmers, People who program using a language X(X people) and people who program using a language Y(Y people).
Both are equally good languages but there is no translator that could translate X language to Y and vice versa.Apologists of X and Y can argue for hours proving each other that their programming language is the best one.Y people will tell that their programs are clearer and less prone to errors, while X people will laugh at their inability to instantiate an array of generics or tell them that their programs are slow and have long source code. Another issue that X and Y people could never agree on is identifier naming. In Y a multiword identifier is constructed in the following manner: the first word is written starting from the small letter, and the following ones are written starting from the capital letter, no separators are used.
All other letters are small. Examples of a Y identifier are yIdentifier,longAndMnemonicIdentifier,name,nEERC.Unlike them, X people use only small letters in their identifiers. To separate words they use underscore character "_". Examples of X identifiers are x_identifier, long_and_mnemonic_identifier, name (you see that when there is just one word X and Y people agree), n_e_e_r_c.
Your job is to write a translator that is intended to translate programs in X to Y and vice versa. Of course, identifiers in the translated program must be formatted due to its language rules - otherwise people will never like your translator. 

The first thing you would like to write is an identifier translation routine. Given an identifier,
it would detect whether it is Y identifier or X identifier and translate it to another dialect. If it is neither, then your routine should report an error.
Translation must preserve the order of words and must only change the case of letters and/or add/remove underscores.


N, Number of testcases 0<N<=50
N lines, that contains an identifier. It consists of letters of the English alphabet and underscores. Its length does not exceed 100.


If the input identifier is Y identifier, output its X version. If it is X identifier, output its Y version. If it is none, output "Error!" instead.

Sample Input:


Sample Output:


class CharDemo
public static void main(String a[]) throws IOException

BufferedReader in=new BufferedReader(new InputStreamReader(;
int test=Integer.parseInt(in.readLine());

String input[]=new String[test];

for(int i=0;i<test;i++)

String output[]=new String[test];

for(int k=0;k<test;k++)
int m=0;
char[] arr=input[k].toCharArray();
char temp[]=new char[arr.length+6];
for(int i=0;i<arr.length;i++)

else if(arr[i]=='_')
for(int f=0;f<"Error!".length();f++)

output[k]=new String(temp);


for(int k=0;k<test;k++)



  1. These loans are uncertain in nature and in the short term, because they offer the amount from £ 100 up to £ 1,000 for a limited period, 14-31 days bad credit loans. The plus point of this aid is rare on security against the crowd payday loans no credit check. Another plus point is that you can extend the time to pay a symbolic fee for the creditor. To do this, you can avoid unwanted. The interest rate charged is higher than regular loans payday loans lenders. This may be different from the less efficient search through the online marketplace, where you'll find many lenders with their Web pages, as they are ready to provide the best solutions in the competition.

  2. . The reimbursement span of the sum is for the brief time of time. The candidates have the capacity to pay back the acquired sum inside 7 days just. text loan

  3. Job Oriented IT Online Training -H1B Visa, Work Permit and Job Placements
    5000 IT certified Consultants.Register at

  4. I have been following you for a couple of months now but this is my first time commenting on a blog post. Thank you for sharing your knowledge and experience with us. Keep up the good work. Already bookmarked for future reference.

    SAP training in Chennai

  5. All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.

    Digital Marketing Training in Chennai


  6. nice blog too informative. looking and reading your points its so impressive. doing more blog like this. i really appreciated doing like this.

    Digital Marketing For Small Business in Chennai

  7. Thank you for sharing such a nice and interesting blog with us. I have seen that all will say the same thing repeatedly. But in your blog, I had a chance to get some useful and unique information. I would like to suggest your blog in my dude circle.
    Isoft Innovations Company Address
    Isoft Innovations Adyar
    Isoft Innovations Reviews
    Isoft Innovation Chennai
    Isoft Innovation

  8. These provided information was really so nice,thanks for giving that post and the more skills to develop after refer that post. Your articles really impressed for me,because of all information so nice.

    Best Laser Clinic In Chennai

    Best Implant Clinic In Chennai