U3 Hacks
Lessons
public class comparing {
public static String compareString(String string1, String string2) {
String bigString = "";
int yeah = string1.compareTo(string2);
if (yeah>0) {
bigString = string1;
}
else if (yeah<0) {
bigString = string2;
}
else {
bigString = "They are the same";
}
return bigString;
}
public static int compareInt(int int1, int int2) {
int greater = 0;
if (int1>int2) {
greater = int1;
}
else if (int2>int1) {
greater = int2;
}
return greater;
}
public static void main(String[] args) {
System.out.println(compareString("no", "yes"));
System.out.println(compareString("yes", "rag"));
System.out.println(compareString("yes", "yes"));
System.out.println(compareInt(17, 23));
}
}
comparing.main(null);
yes
yes
They are the same
23
Weird Questions
- !(true)&&(false) = false
- not ((((true and not (false)) ^ false) ^ true) && false) = true
- !A * !(B + !C) = !A * (!B * C) !(A + (B + !C)) = !A * !(B + !C) !(A + (B + !C)) = !(A + (B + !C))
- 420 && 66 110100100 && 1000010 000000000 Bonus: 89 OR 42 1011001 OR 101010 0001000
Testing for Weird Questions
System.out.println(!(true)&&(false));
System.out.println(!((((true && !(false)) ^ false) ^ true) && false));
// System.out.println(!A * !(B + !C) = !A * (!B * C));
false
true