001-003-004
Variable Initialization: Student Info Card
Easy
Problem Description
Variable Initialization: Student Info Card
Learning Objective
Learn how to initialize variables at the time of declaration.
Problem
Create a program that displays student information.
Receive name and grade as input and display a student info card.
Input
Line 1: Name (string)
Line 2: Grade (integer)
Output
Student: [name]
Grade: [grade].
Test Cases
※ Output examples follow programming industry standards
Input:
Taro 3
Expected Output:
Student: Taro Grade: 3
Input:
Hanako 1
Expected Output:
Student: Hanako Grade: 1
❌ 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
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// [入力準備] Scanner オブジェクトでキーボード入力を受け入れる
Scanner sc = new Scanner(System.in);
// 2. 名前変数を初期化
String name = sc.nextLine();
// 3. 成績変数を初期化
int grade = sc.nextInt();
// 学生情報を表示
System.out.println("Student: " + name);
// [出力処理] 結果を画面に表示
System.out.println("Grade: " + grade);
}
}
0 B / 5 MB
You have 10 free executions remaining
