aspose file tools*
The moose likes I/O and Streams and the fly likes PW printing nothing(may not be an io issue) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "PW printing nothing(may not be an io issue)" Watch "PW printing nothing(may not be an io issue)" New topic
Author

PW printing nothing(may not be an io issue)

Samuel Bird
Ranch Hand

Joined: Jul 19, 2013
Posts: 96

I am not sure if this is an IO issue or not but I couldn't think of anywhere else to put it. I have written a program that does the task here: http://cerberus.delos.com:790/usacoprob2?S=friday&a=fame6Eah0fH. However, it only ends up printing a series of 0's. I have been on this for hours and was hoping that someone else may be able to offer an insight as to what is wrong. I apologise for the ambiguity but I am really not sure what is wrong. There are no errors so it is likely just a flaw and, if so, I would appreciate advice on what it is. If this is in the wrong section I apologise and please move it. Thanks, Sam.

code:



edit: the error shown on the USACO compiler and tester was this:

Samuel Bird
Ranch Hand

Joined: Jul 19, 2013
Posts: 96

I have actually removed the 0's by removing the break!

However, it is still not right. Any ideas?

error:



UPDATE:

I have removed new line issue which was trivial(make it println) and have fixed what I believe to be an issue at
to stop it going a month ahead. This didn't fix it however. New error has replaced the old! P.s.I changed it at the other identical for loop also.
Samuel Bird
Ranch Hand

Joined: Jul 19, 2013
Posts: 96

I have fixed a few bugs(added continues, fixed the 'day' value):



However, it is still not working with an error line of:



so I thought that as their output adds up to 12 for 1 13th of the month every month for a year, I should see what mine adds up to. It adds up to 311 which divided by 12 is 25.96 which I will put down to java type manipulation so Ill say that it does the equivalent of 26 years when it is meant to do one year. Therefore, I assume the issue is to do with the higher level stuff like the years. However,I still can't find the issue.
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3739
    
  16
You need to debug your code and check that the values of all the variables are correct at every step through the program.
The easiest way to do this is with a debugger, but if you haven't used a debugger before it can be complicated.
It might be better to start off be just putting lots of print statements in your code to print out the values of the variables at various points in your program.


Joanne
Samuel Bird
Ranch Hand

Joined: Jul 19, 2013
Posts: 96

Thanks, ill try it.
Samuel Bird
Ranch Hand

Joined: Jul 19, 2013
Posts: 96

Hmmm, adding a print statement here and setting N to 1 which is what USACO inputs when it fails gives the the right answer. Even worse, their servers seem to be down or something because I cannot connect.

 
jQuery in Action, 2nd edition
 
subject: PW printing nothing(may not be an io issue)