Psywar Posted July 1, 2015 Posted July 1, 2015 Hey ya'll! I am working on my final programming project and I am stuck. My code runs with no errors, but my output is wrong. When you look at the code you are going to wonder why I am not using a calendar function that is built in and the answer is I am not allowed to. When you run my code you get 3 options. Option 1 allows you to choose a day of the week. It will tell you the next day, the previous day, and then it will ask you to input how many days in advance you want it to be. If I recall right on option 1 when you enter in the advance days it never returns the correct day. Option 2 is my testing option. It has a static day set (Sunday). Here is the output: As you can see from the photo adding 9 days, previous day, and add 3 days is totally wrong. EDIT: I actually just realized I uploaded the wrong screen capture. This photo is right. I was hoping someone could help me out with this as I have been racking my head on it for the last couple days. I have uploaded my code to Google Docs here: https://docs.google.com/document/d/1DRPgN0cK16P-dNpFTzFM074zweX4LN00z5iI8THxe8Y/edit?usp=sharing Thanks for any help! Share this post Link to post Share on other sites More sharing options...
Waco Posted July 1, 2015 Posted July 1, 2015 So at first glance it looks like you're overwriting the variable holding the initial day. I haven't looked at the code at all though, but the increments and decrements all appear correct based on the previous answer. Share this post Link to post Share on other sites More sharing options...
Psywar Posted July 1, 2015 Posted July 1, 2015 Hrmm.. that is an interesting thought.. I looked through the code and if I am, I cannot figure out where. I dunno.. I made another version of this program and it works, but it does not have the menu this one has and it also does not have a way to test the code like this version has. However it does work correctly and it sounds like my teacher does not care if it has a testing feature or not so I might just turn that one in. Share this post Link to post Share on other sites More sharing options...
Psywar Posted July 2, 2015 Posted July 2, 2015 Fixed the issue: Line 94 I added the code: theDay.setDay(theDay.getNextDay()); theDay.setDay(theDay.addDays(days)); fixed the issue right up. Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now