Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- public int diff21(int n) {
- if (n > 21) {
- return (n - 21)*2;
- } else {
- return 21 - n;
- }
- }
- //
- public boolean parrotTrouble(boolean talking, int hour) {
- if (talking && (hour > 20 || hour < 7)) {
- return true;
- } else {
- return false;
- }
- }
- //
- public boolean makes10(int a, int b) {
- if (a == 10 || b == 10 || a + b == 10) {
- return true;
- } else {
- return false;
- }
- }
- //
- public boolean nearHundred(int n) {
- if (Math.abs(n - 100) <= 10 || Math.abs(n - 200) <= 10) {
- return true;
- } else {
- return false;
- }
- }
- //
- public boolean posNeg(int a, int b, boolean negative) {
- if (negative) {
- return (a < 0 && b < 0);
- }
- else {
- return ((a < 0 && b > 0) || (a > 0 && b < 0));
- }
- }
- //
- public String notString(String str) {
- if (str.startsWith("not")) {
- return str;
- } else {
- return "not " + str;
- }
- }
- //
- public String missingChar(String str, int n) {
- String front = str.substring(0, n);
- String back = str.substring(n+1, str.length());
- return front + back;
- }
- //
- public String frontBack(String str) {
- if (str.length() < 2) {
- return str;
- } else {
- char fletter = str.charAt(0);
- char lletter = str.charAt(str.length() - 1);
- String middle = str.substring(1, str.length() - 1);
- return lletter + middle + fletter;
- }
- }
- //
- public String front3(String str) {
- if (str.length() < 3) {
- return str + str + str;
- } else {
- String start = str.substring(0, 3);
- return start + start + start;
- }
- }
- //
- public String backAround(String str) {
- char c1 = str.charAt(str.length() - 1);
- return c1 + str + c1;
- }
- //
- public boolean or35(int n) {
- if(n%3 == 0 || n%5 == 0) {
- return true;
- } else {
- return false;
- }
- }
- //
- public String front22(String str) {
- if(str.length() < 3) {
- return str + str + str;
- } else {
- String s1 = str.substring(0,2);
- return s1 + str + s1;
- }
- }
- //
- public boolean startHi(String str) {
- if(str.startsWith("hi")) {
- return true;
- } else {
- return false;
- }
- }
- //
- public boolean icyHot(int temp1, int temp2) {
- if ((temp1 > 100 && temp2 < 0) || (temp1 < 0 && temp2 > 100)) {
- return true;
- } else {
- return false;
- }
- }
- //
- public boolean in1020(int a, int b) {
- if ((a <= 20 && a >= 10) || (b <= 20 && b >= 10)) {
- return true;
- } else {
- return false;
- }
- }
- //
- public boolean hasTeen(int a, int b, int c) {
- if ((a <= 19 && a >= 13) || (b <= 19 && b >= 13) || (c <= 19 && c >= 13)) {
- return true;
- } else {
- return false;
- }
- }
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement