011-002-007
Constructor Call: Creating Multiple Objects
Easy
Problem Description
constructor Call: Creating Multiple Objects
Learning Objective: Call constructor with new keyword to create objects
In this problem, you will create a program that calls the Student class constructor twice using the new keyword to instantiate two independent student objects, then displays each student's name and score to standard output.
Create a program managing two students' information. Call the Student class constructor with the new keyword to create independent objects for each student.
Input
Line 1: Student 1 name (string)
Line 2: Student 1 score (integer)
Line 3: Student 2 name (string)
Line 4: Student 2 score (integer)
Output
Student 1: [name] - [score] points
Student 2: [name] - [score] points
Examples
Example 1: Basic values
Input:
Taro
85
Hanako
92
Output:
Student 1: Taro - 85 points
Student 2: Hanako - 92 points
Example 2: Different values
Input:
Ichiro
70
Jiro
80
Output:
Student 1: Ichiro - 70 points
Student 2: Jiro - 80 points
Example 3: Boundary values
Input:
A
0
B
100
Output:
Student 1: A - 0 points
Student 2: B - 100 points
Test Cases
※ Output examples follow programming industry standards
Input:
Taro 85 Hanako 92
Expected Output:
Student 1: Taro - 85 points Student 2: Hanako - 92 points
Input:
Ichiro 70 Jiro 80
Expected Output:
Student 1: Ichiro - 70 points Student 2: Jiro - 80 points
Input:
A 0 B 100
Expected Output:
Student 1: A - 0 points Student 2: B - 100 points
Input:
Alice 90 Bob 75
Expected Output:
Student 1: Alice - 90 points Student 2: Bob - 75 points
❌ Some tests failed
Your Solution
Current Mode:● My Code
Student.java🔒
Solution.java🔒
2/6 ファイル96B
⚠️警告
- No main method found
9
1
2
3
4
›
⌄
import java.util.Scanner;
class Student {
}
0 B / 5 MB
You have 8 free executions remaining
