File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Input/output Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Input/output" Watch "Input/output" New topic
Author

Input/output

Manish Vig
Greenhorn

Joined: Oct 03, 2000
Posts: 8
Dear Friends
Can you help me wit this code and its result.
I was trying to get the sum of a five digit number when i stumbled upon this
<code>
import java.io.*;
class Sum{
public static void main(String args[])throws Exception
{ int d=0;
DataInputStream dis= new DataInputStream(System.in);
int k=dis.readInt();
for(int i=0;i<5;i++)
{
d=k%10;
System.out.println(d);
d+=d;
k/=10;
System.out.println(k);
}
System.out.println(d);
}
}
</code>
The result is absolutely stupefying with the no 12345
Say.
Why is this.
Is it because this method is only suitable for reading bytes written by DataOutputStream.

[This message has been edited by Manish Vig (edited October 31, 2000).]
 
 
subject: Input/output
 
Threads others viewed
open a pdf inline using MIME in ie7
Scanner class help
For loop error?
?? no idea
Sum Of Digits
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture