class Chu
public static void main(String args[])throws Exception
char i;
BufferedReader d=new BufferedReader(new InputStreamReader(;

Please explain what you code does that is not what you want it to do.
Post the output from the program and explain what is wrong with the output and show what you want the output to be.

A suggestion for debugging: Do the steps one at a time and print out the results of each step. Do NOT do more than one thing in each step.
Break the above into two steps and print out the results for each step.