I am trying to write a code which if the following conditions are met it will say marry me otherwise it would say get lost.
Conditions which need to be met:
22 to 27 year old male, non-smoking, under 72 inches tall, under 160 pounds, good-looking, able to relocate.”
This is the code I have so far written. However, it prints get lost even though I believe it matches the given criteria? What is wrong?
Furthermore, how can I put it in terms of a single boolean?
public class marry {
public static void main(String[] args) {
int weight = 150;
int age = 24;
int height = 71;
boolean isASmoker = false;
boolean isMale = true;
boolean isGoodLooking = true;
boolean isAbleToRelocate = true;
if (((weight < 160 && (age <= 27 && age >= 22)) && ((height < 72) && ((isASmoker = false) && (isMale = true))) && ((isGoodLooking = true) && (isAbleToRelocate = true)))) {
System.out.println("Marry Me!");
}
else {
System.out.println("Get Lost!");
}
}
}
Thanks
=
to compare values, you have to use==
in java.