007-003-001

Class Usage: Bank Account

Easy

Problem Description

class Usage: Bank Account

Learning Objective: Manage state using class

In this problem, you will create a program that implements a BankAccount class with a balance field and a deposit() method, receives an initial balance and deposit amount, updates the balance, and displays the result to standard output.

Create a program using a bank account class to check balance and make a deposit. Implement a BankAccount class that stores the initial balance, then add a deposit(int amount) method that updates the balance when called.

Input

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

Output

Initial balance: [balance] yen
After deposit: [balance] yen

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
1000
500
Expected Output:
Initial balance: 1000 yen
After deposit: 1500 yen
Normal case
Input:
5000
2000
Expected Output:
Initial balance: 5000 yen
After deposit: 7000 yen

Your Solution

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

class BankAccount {
}
0 B / 5 MB

You have 10 free executions remaining