hello,
i wrote very simple code for reversing integer digits. but when i compile it, i get message as
----jGRASP exec: javac -g C:\Program Files\Java\jdk1.6.0_23\bin\ReverseDigit.java
---- at: Mar 14, 2011 7:58:58 PM
----jGRASP wedge: pid for wedge is 4920.
----jGRASP wedge2: pid for wedge2 is 1788.
----jGRASP wedge2: CLASSPATH is ".;;.;C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip;C:\Program Files (x86)\jGRASP\extensions\classes".
----jGRASP wedge2: working directory is [C:\Program Files\Java\jdk1.6.0_23\bin] platform id is 2.
----jGRASP wedge2: actual command sent ["C:\Program Files\Java\jdk1.6.0_23\bin\javac.exe" -g "C:\Program Files\Java\jdk1.6.0_23\bin\ReverseDigit.java"].
----jGRASP wedge2: pid for process is 5984.
----jGRASP wedge2: exit code for process is 0.
----jGRASP: operation complete.
The code runs. but does not give any output.
I put some out.print statements to find out what's happening. my program does not take value inputed. my code is:
import java.util.Scanner;
public class ReverseDigit
{
public static void main( String args[] )
{
int number,newnumber1;
Scanner input = new Scanner( System.in );
System.out.print( "Enter the number to be reversed\n" );
number = input.nextInt();
newnumber1 = reverseInt(number);
System.out.printf( "::: ",number );
System.out.printf( "The reversed number is: ",newnumber1 );
}
public static int reverseInt(int num1)
{
int digit1,digit2,digit3,digit4;
int newnumber;
digit1 = num1/1000;
digit2 = num1/100 - digit1*10;
digit3 = num1/10 - digit1*100 - digit2*10;
digit4 = num1 - digit1*1000 - digit2*100 - digit3*10;
newnumber = (digit4 * 1000) + (digit3 * 100)+ (digit2 * 10) + digit1;
System.out.printf( ": ",newnumber );
return newnumber;
}
}
and the output i get is:
Enter the number to be reversed
1234
: ::: The reversed number is:
what could be the problem?