I'm sorry Burak, but we try not supply direct answers to assignment/interview questions or provide ready made code samples (please, have a read of this).
We will however help you work through the coding problems you are having. So, what have you tried? Can you post the code you've got so far? Or if you've got nothing, can you explain what is confusing you?
You don't seem to understand our mission here. We want to HELP you LEARN to program. you CANNOT learn to program by being handed an answer. the only way to learn is to do it yourself. Ask questions. try writing code. experiment. make mistakes and learn to not make them again.
Whether you pass or fail your exam is not our concern or problem. Personally, i don't want someone to pass a Java exam who can't program. Would you want a doctor to operate on you who doesn't know a kidney from a spleen? would you want someone to chauffeur you around who doesn't understand the rules of the road?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors