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
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