This week's book giveaways are in the iOS and Features new in Java 8 forums.
We're giving away four copies each of Barcodes with iOS: Bringing together the digital and physical worlds and Core Java for the Impatient and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes program able to compile and execute but output was wrong. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Barcodes with iOS this week in the iOS forum
or Core Java for the Impatient in the Java 8 forum!

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "program able to compile and execute but output was wrong." Watch "program able to compile and execute but output was wrong." New topic
Author

program able to compile and execute but output was wrong.

Ayukawa Madoka
Greenhorn

Joined: Feb 28, 2004
Posts: 27
i'm writing a program that accepts an integer value from a user and determine whether it's an even or odd number and then displays the integer taken from the user onto the screen. the program was able to compile and execute but the weird thing is the display result wasn't correct. is there anything wrong with my program? or the method that i used to differentiate between even and odd number is wrong? :roll:



hello everyone i'm new here.
Will Carpenter
Greenhorn

Joined: Mar 17, 2004
Posts: 26
I always have problems with System.in.read() when trying to accept mathematical input. I think it's because the Carriage Return and Next Line Characters that happen each time you hit "enter" get added onto the character that was entered. Try using a BufferedReader.
Will Carpenter
Greenhorn

Joined: Mar 17, 2004
Posts: 26
See for example the answers to my earlier posts entitled "Input from keyboard" in which I encountered a similiar problem....
Ayukawa Madoka
Greenhorn

Joined: Feb 28, 2004
Posts: 27
i see. ok thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: program able to compile and execute but output was wrong.