009-001-006

private Modifier: Account Information

Easy

Problem Description

private Modifier: Account Information

In this problem, you will create a program that builds an Account class with private fields (username and balance), retrieves values through public getter methods, and displays the result to standard output.

Learning Objective: Understand private fields and public getters

Define username and balance as private fields in the Account class and receive initial values through a constructor. Implement getUsername() and getBalance() getter methods that return the corresponding field values.

Input

Line 1: Username (string)
Line 2: Balance (integer)

Output

Username: [username]
Balance: [balance] yen

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
Taro
10000
Expected Output:
Username: Taro
Balance: 10000 yen
Normal case
Input:
Hanako
5000
Expected Output:
Username: Hanako
Balance: 5000 yen

Your Solution

Current Mode: My Code
Account.java🔒
Solution.java🔒
2/6 ファイル96B
⚠️警告
  • No main method found
import java.util.Scanner;

class Account {
}
0 B / 5 MB

You have 10 free executions remaining