011-001-002
Constructor Definition: Product Information
Easy
Problem Description
constructor Definition: Product Information
In this problem, you will create a program that defines a Product class which receives a product name, unit price, and quantity in its constructor, calculates the total amount, and displays the result to standard output.
Learning Objective: Perform calculations in constructor
Create class managing product information. Receive unit price and quantity in constructor, calculate total amount.
Input
Line 1: Product name (string)
Line 2: Unit price (integer)
Line 3: Quantity (integer)
Output
Product: [name]
Unit price: [price] yen
Quantity: [quantity] items
Total: [total] yen
Test Cases
※ Output examples follow programming industry standards
Normal case
Input:
Apple 100 3
Expected Output:
Product: Apple Unit price: 100 yen Quantity: 3 items Total: 300 yen
Normal case
Input:
Banana 150 2
Expected Output:
Product: Banana Unit price: 150 yen Quantity: 2 items Total: 300 yen
Your Solution
Current Mode:● My Code
Product.java🔒
Solution.java🔒
2/6 ファイル96B
⚠️警告
- No main method found
9
1
2
3
4
›
⌄
import java.util.Scanner;
class Product {
}
0 B / 5 MB
You have 10 free executions remaining
