954,549 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Boolean exercise

hi every one

I have a exercise when i going to use boolean.

Im need to do 3 intergervaribals var1 var2 var3 and then i get same claim im going to get in to it like one of it is: The number var1 is evenly divisible by 7.

i figuer out that i can use samthing like this.
boolean sv = (var1%7 == 0);
System.out.println(sv);
i know how to do the boolean and look if its true or not but i dont know how to use it when im going to get 3 diffrent intergervaribals

plz can anyone show my how you type this program so i can understand it. and its only a exercise so i dont need to show it to anyone its only for my self to learn, so its no real homework that

Sanna.1
Newbie Poster
7 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

what is gonna be the diference between the 1 variable example and 3 variable example?

will you need to repeat the 1 variable technique on each of the 3 variables? Or you need to know if var1 is divisible by var 2 or something like that? it is not very clear in your post

Philippe.Lahaie
Posting Whiz
326 posts since Oct 2007
Reputation Points: 103
Solved Threads: 45
 

Please use code tags to display code on this forum, to make it more readable for the people that have to answer you.
Also, please try to construct normal sentences, so we will be able to understand you.

Ontopic:
You can do exactly what you already showed.

boolean bool1 = (var1 % 7 == 0);
boolean bool2 = (var2 % 7 == 0);
boolean bool3 = (var3 % 7 == 0);


and so on...

hiddepolen
Posting Whiz in Training
297 posts since Oct 2010
Reputation Points: 82
Solved Threads: 35
 

or :

private boolean getBoolean(){
if ( expression1 && expresssion2 && expression3 )
    return true;
return false;
}
stultuske
Posting Sensei
3,137 posts since Jan 2007
Reputation Points: 1,114
Solved Threads: 433
 

or, more simply:

private boolean getBoolean(){
    return   expression1 && expresssion2 && expression3 ;
 }
JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: