009-001-004

Private Modifier: Bank Account

Medium

Problem Description

Private Modifier: Bank Account

In this problem, you will create a program that implements a BankAccount class with a private balance field accessed through getter and setter methods, performs a deposit operation, and displays the result to standard output.

Learning Objective: Understand encapsulation using private

Create a BankAccount class that hides balance with private and accesses it through getter and setter.

Input

Line 1: Initial balance (integer)
Line 2: Deposit amount (integer)

Output

Initial: [initial balance] yen
Deposit: [deposit amount] yen
Balance: [final balance] yen

Example

Input:

1000
500

Output:

Initial: 1000 yen
Deposit: 500 yen
Balance: 1500 yen

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