This is a coding challenge/contest, it is set to test your coding skills. Since you ask us to do it, the answer is that you need to sharpen your skills because you are unable to solve the problem yourself.
You posted the question in a way that prevent any help.
In this kind of challenge, every word matters. So you need to post exact statement.
A link to actual page of challenge is a good idea too.
Quote:
Given N number of x’'s, perform logic equivalent of the above Java code and print the output
The logic equivalent of the code is the code itself.
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work.