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

Recommended Answers

All 4 Replies

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

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...

or :

private boolean getBoolean(){
if ( expression1 && expresssion2 && expression3 )
    return true;
return false;
}

or, more simply:

private boolean getBoolean(){
    return   expression1 && expresssion2 && expression3 ;
 }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.