002-004-002
Input Validation: Test Score Check
Easy
Problem Description
Input Validation: Test Score Check
Learning Objective: Check if input is within 0-100 range
In a test score input program, verify score is within valid range (0-100).
Input
Line 1: Score (integer)
Output
Within 0-100:
Valid score
Score: [score] pts
```java
Out of range:
```java
Invalid score
Test Cases
※ Output examples follow programming industry standards
Input:
85
Expected Output:
Valid score Score: 85 pts
Input:
100
Expected Output:
Valid score Score: 100 pts
Input:
120
Expected Output:
Invalid score
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
›
⌄
⌄
⌄
⌄
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
// キーボードからのユーザー入力を読むためのScannerオブジェクトを準備
Scanner sc = new Scanner(System.in);
// スコアを受け取る
int score = sc.nextInt();
// 範囲チェック(0以上100以下)
if (score >= 0 && score <= 100) {
System.out.println("Valid score");
System.out.println("Score: " + score + " pts");
} else {
System.out.println("Invalid score");
}
}
}
0 B / 5 MB
You have 10 free executions remaining
