hasTeen

We’ll say that a number is “teen” if it is in the range 13..19 inclusive. Given 3 int values, return true if 1 or more of them are teen.

hasTeen(13, 20, 10) ? true
hasTeen(20, 19, 10) ? true
hasTeen(20, 10, 13) ? true

public boolean hasTeen(int a, int b, int c) {
if(a>=13 && a<=19) return true;
else if(b>=13 && b<=19) return true;
else if(c>=13 && c<=19) 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