007-002-008
Object Creation: Student Class
Medium
Problem Description
Object Creation: Student class
In this problem, you will create a program that defines a Student class with name and age fields, instantiates two student objects from standard input, and displays each student's information to standard output.
Learning Objective: Create objects from classes and handle multiple instances
Create a class representing students and generate multiple student objects.
Input
Line 1: First student's name (string)
Line 2: First student's age (integer)
Line 3: Second student's name (string)
Line 4: Second student's age (integer)
Output
Student 1: [name] (Age: [age])
Student 2: [name] (Age: [age])
Examples
Example 1
Input:
Taro
20
Hanako
19
Output:
Student 1: Taro (Age: 20)
Student 2: Hanako (Age: 19)
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up