003-002-001

Comparison Operators: Age Comparison

Easy

Problem Description

Comparison Operators: Age Comparison

In this problem, you will create a program that reads two integer ages, compares them using comparison operators (>, <, ==) combined with if-else statements, and displays the result to standard output.

Learning Objective: Learn to combine comparison operators (>, <, ==) with if-else statements to evaluate multiple conditions

Compare ages of two people and determine who is older. Use comparison operators and if-else statements to check magnitude relationships.

Input

Line 1: Person A age (integer)
Line 2: Person B age (integer)

Output

If A is older:

Person A: [age1] years old
Person B: [age2] years old
Person A is older
```java
If B is older:
```java
Person A: [age1] years old
Person B: [age2] years old
Person B is older
```java
If same age:
```java
Person A: [age1] years old
Person B: [age2] years old
Same age

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
30
25
Expected Output:
Person A: 30 years old
Person B: 25 years old
Person A is older
Normal case
Input:
20
35
Expected Output:
Person A: 20 years old
Person B: 35 years old
Person B is older

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 10 free executions remaining