+ 2
How get output hi?
public class Program { public static void main(String[] args) { int age = 16; int money = 400; if (age > 18) { if (money > 500) { System.out.println("Welcome!"); } else { System.out.println("hi"); } } } }
3 Respuestas
+ 6
Well we have 2 conditions here:-
✅ Is age > 18?
✅ Is money > 500?
In order to get "hi" as the output, we need to ensure the 1st condition is true while the 2nd condition is false.
Therefore, one of the desired input would be:-
age = 19 (minimum)
money = 500 (maximum)
+ 2
int age = 20;
+ 2
Zephyr Koo If money == 501 then the output is "Welcome!". You said it yourself: the condition money>500 needs to be false.
EDIT: Nevermind.