003-002-006

Comparison Operators: Score Ranking

Easy

Problem Description

Comparison Operators: Score Ranking

Learning Objective: Determine magnitude with comparison operators

Compare test scores of two people and determine who has higher score. Decide ranking using comparison operators.

Input

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

Output

If A has higher score:

Person A: [score1] pts
Person B: [score2] pts
Person A is 1st
```java
If B has higher score:
```java
Person A: [score1] pts
Person B: [score2] pts
Person B is 1st
```java
If tied:
```java
Person A: [score1] pts
Person B: [score2] pts
Tied

Test Cases

※ Output examples follow programming industry standards

Input:
85
72
Expected Output:
Person A: 85 pts
Person B: 72 pts
Person A is 1st
Input:
68
95
Expected Output:
Person A: 68 pts
Person B: 95 pts
Person B is 1st
Input:
80
80
Expected Output:
Person A: 80 pts
Person B: 80 pts
Tied
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
// ユーザー入力を読むためのキーボードからの入力を読むScannerオブジェクトを作成
Scanner sc = new Scanner(System.in);
// ユーザーからの入力値を読んで格納
int scoreA = sc.nextInt();
// ユーザーからの入力値を読んで格納
int scoreB = sc.nextInt();
// コンソール経由でユーザーに出力を表示
System.out.println("Person A: " + scoreA + " pts");
// コンソール経由でユーザーに出力を表示
System.out.println("Person B: " + scoreB + " pts");
// 条件をチェック
if (scoreA > scoreB) {
// コンソール経由でユーザーに出力を表示
System.out.println("Person A is 1st");
} else if (scoreA < scoreB) {
// コンソール経由でユーザーに出力を表示
System.out.println("Person B is 1st");
} else {
// コンソール経由でユーザーに出力を表示
System.out.println("Tied");
}
}
}

0 B / 5 MB

You have 10 free executions remaining