011-003-003
This Keyword: Self Reference
Easy
Problem Description
This Keyword: Self Reference
Learning Objective: Understand how to reference current object using this keyword
Create a Product class and use this to distinguish fields from arguments with same names. This refers to the current object itself.
Input
Line 1: Product name (string)
Line 2: Price (integer)
Output
Product: [product name]
Price: [price] yen
Test Cases
※ Output examples follow programming industry standards
Input:
Laptop 150000
Expected Output:
Product: Laptop Price: 150000 ¥
Input:
Pen 100
Expected Output:
Product: Pen Price: 100 ¥
Input:
Free Sample 0
Expected Output:
Product: Free Sample Price: 0 ¥
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 9 free executions remaining
