014-003-001

Explicit super: Book Class

Easy

Problem Description

Explicit super: Book class

In this problem, you will create a program that extends a Product class with a Book class, calls the parent constructor using super(), and displays the product name, price, author name, and type to standard output.

Learning Objective: Initialize parent with super while having child-specific fields

Create a Product class representing products and a Book class inheriting from it. The Book class has its own field (author) while calling the parent class constructor with super().

Input

Line 1: Product name (string)
Line 2: Price (integer)
Line 3: Author name (string)

Output

Name: [product name]
Price: [price]yen
Author: [author name]
Type: Book

Examples

Example 1: Basic book

Input:

JavaBook
2800
Tanaka

Output:

Name: JavaBook
Price: 2800yen
Author: Tanaka
Type: Book

Example 2: Different book

Input:

PythonGuide
3500
Sato

Output:

Name: PythonGuide
Price: 3500yen
Author: Sato
Type: Book

Example 3: Boundary (minimum price)

Input:

A
1
B

Output:

Name: A
Price: 1yen
Author: B
Type: Book

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
CookingMaster
1980
Yamamoto
Expected Output:
Name: CookingMaster
Price: 1980yen
Author: Yamamoto
Type: Book
Normal case
Input:
HistoryAtlas
4200
Kobayashi
Expected Output:
Name: HistoryAtlas
Price: 4200yen
Author: Kobayashi
Type: Book

Your Solution

Current Mode: My Code
Product.java🔒
Book.java🔒
Solution.java🔒
3/6 ファイル164B
public class Product {
}
0 B / 5 MB

You have 10 free executions remaining