We'll say that a number is "teen" if it is in the range 13..19 inclusive. Given 2 int values, return true if one or the other is teen, but not both.
solution:
package congcong;
public class loneTeen {
public static void main(String[] args) {
// TODO Auto-generated method stub
boolean a=loneTeen(13,99);
boolean b=loneTeen(21,19);
boolean c=loneTeen(13,13);
System.out.println(a);
System.out.println(b);
System.out.println(c);
}
private static boolean loneTeen(int a, int b) {
// TODO Auto-generated method stub
boolean aTeen=(a>=13&&a<=19);
boolean bTeen=(b>=13&&b<=19);
return (aTeen&&!bTeen)||(!aTeen&&bTeen);
}
}
网友评论