• Post Reply Bookmark Topic Watch Topic
  • New Topic

Learning Exponent Operations in Java  RSS feed

 
John Joe
Ranch Hand
Posts: 433
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys , I'm learning java by reading "Introduction Java Programming". I have two question cannot solve in topic Exponent Operations

1. What is the amount of memory required for storing variables of the following types: char and Boolean ?
2. If today is Friday, what will be the day in 50 days ?

Anyone has the answer ? Thanks .
 
John Joe
Ranch Hand
Posts: 433
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get the answer for the 2nd question

2. If today is Friday, what will be the day in 50 days ?


Answer : System.out.println((5+50)%7);

I'm still looking for the first question answer . 
 
Piet Souris
Master Rancher
Posts: 2044
75
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Joe wrote:I get the answer for the 2nd question

2. If today is Friday, what will be the day in 50 days ?


Answer : System.out.println((5+50)%7);

I'm still looking for the first question answer . 

For the size of primitives, have a look here:
oracle tutorial

For your day 50 days ahead: (5 + 50) % 7 is indeed correct, giving 6. What day of the week do we have then, and how do you print that on the screen?
 
John Joe
Ranch Hand
Posts: 433
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Piet Souris wrote:
For your day 50 days ahead: (5 + 50) % 7 is indeed correct, giving 6. What day of the week do we have then, and how do you print that on the screen?


Saturday and use System.out.println to print out the value .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!