• Post Reply Bookmark Topic Watch Topic
  • New Topic

Find future dates  RSS feed

 
John Joe
Ranch Hand
Posts: 436
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Write a program that prompts the user to enter an integer for today's day of the week(Sunday is 0,Monday is 1..., ...).Also prompt the user to enter the number of days after today for a future day and display the future day of the week.Here are the example:
Enter today's day:0
Enter the number of days elapsed since today:31
Today is Sunday and the future day is Wednesday

Here are my code

Output
Enter today's day: 0
Enter the number of days elapsed since today: 31
Today is Sunday and the future day is


How can I get the Wednesday as future day?
 
Vasyl Lyashkevych
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to add this code:

       


As result you will have :

 
Knute Snortum
Sheriff
Posts: 4279
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vasyl Lyashkevych: Thank you for your contribution.  However, in the Beginning Java forum, we avoid giving complete solutions and instead try to lead the OP to their own solution.  After the OP has posted a solution, you are free to post improvements if you wish.
 
Vasyl Lyashkevych
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum (Sheriff), thank you!
I will have it in mind and will try to be an appropriate tutor if I can.

Have a nice time for working!
 
John Joe
Ranch Hand
Posts: 436
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell me the logic ? I used your code but the output is wrong
 
John Joe
Ranch Hand
Posts: 436
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the answer. I changed this line and it works now.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why %4?  that seems wrong to me...i would think %7...
 
John Joe
Ranch Hand
Posts: 436
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:Why %4?  that seems wrong to me...i would think %7...

You're right
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!