Complete the program that takes Alice's and Bob's ages as input and determines whether Alice is older, younger, or the same age as Bob.
Comparing values. Relational operators
Alice and Bob
Report a typo
Fill in the gaps with the relevant elements
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int aliceAge = scanner.nextInt();
int bobAge = scanner.nextInt();
String comparisonResult;
if (aliceAge bobAge) {
comparisonResult = "older than";
} else if (aliceAge bobAge) {
comparisonResult = "the same age as";
} else {
comparisonResult "younger than";
}
System.out.println("Alice is " + comparisonResult + " Bob.");
}
}Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.