in1020

Given 2 int values, return true if either of them is in the range 10..20 inclusive.

in1020(12, 99) ? true
in1020(21, 12) ? true
in1020(8, 99) ? false

public boolean in1020(int a, int b) {
if((a==b) && ((a>=10 && a<=20)&&(b>=10 && b<=20) )) return true;
else if( (a>=10 && a<=20)&&(b<10 || b>20) ) return true;
else if( (b>=10 && b<=20)&&(a<10 || a>20) ) return true;
else return false;

}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s