Simple problem

I have to make a program to keep accepting numbers from the user until he enters 0, and to compute the sum of palindrome numbers from the numbers he enters(palindrome number is a number that is the same reversed i.e 11 121 12321)

In my program, i dont know why but when i enter 0 , it does not quit even though i have made checks for that. Here is the code:

import java.io.*;

publicclass PalindromeSum

{

privateint sum;

publicvoid calculate()throws IOException

{

InputStreamReader isr =new InputStreamReader(System.in);

BufferedReader br =new BufferedReader(isr);

System.out.println("Enter a number");

int c = Integer.parseInt(br.readLine());

while (c!=0)

{

String sc = Integer.toString(c);

StringBuffer sb =new StringBuffer(sc);

String scr =new String(sb.reverse());

int d = Integer.parseInt(scr);

int sum = 0;

if (c==d)

sum=sum+c;

}

if (c==0)

System.out.println("Sum is "+sum);

}

}

What im basically doing to check palindromes is that i convert the number into a StringBuffer, reverse that, convert the reversed StringBuffer back into another number and check if number1==number2

[2051 byte] By [Overkilla] at [2007-11-27 8:39:22]
# 1
Try entering 0 in the first go (you would get your answer). After taking the input and checking it for 0, you are not taking another input, hence you do not get out of the loop.Thanks,Jayant
jayantkdasa at 2007-7-12 20:37:17 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanks for that, so i added the line c = Integer.parseInt(br.readLine());at the end of the while , but my next problem is that the sum is always 0!Message was edited by: Overkill
Overkilla at 2007-7-12 20:37:17 > top of Java-index,Java Essentials,Java Programming...
# 3
> ...> at the end of the while , but my next problem is that> the sum is always 0!Yes, what else should it be? Look at what you do inside the while-statement to the sum variable.
prometheuzza at 2007-7-12 20:37:17 > top of Java-index,Java Essentials,Java Programming...
# 4
Omg... Lol im sorry i make such stupid mistakes, and the fact that I post atleast 1 problem i have per day, but im still a student, trying to learn java.Thanks a lot
Overkilla at 2007-7-12 20:37:17 > top of Java-index,Java Essentials,Java Programming...