#C12909. Bank Account Management System
Bank Account Management System
Bank Account Management System
In this problem, you are required to implement a simple bank system that handles account creation, deposits, withdrawals, and balance inquiries. Each account is uniquely identified by an account number and is secured with a personal identification number (PIN). Your task is to implement the following operations:
- CREATE: Create a new account with a given account number and PIN. If an account with the same account number already exists, the operation should fail.
- DEPOSIT: Deposit a given positive amount into an account, if the provided PIN is correct.
- WITHDRAW: Withdraw a given positive amount from an account, if the provided PIN is correct and the account has sufficient balance.
- BALANCE: Check the account balance if the provided PIN is valid; otherwise, return "Invalid PIN".
The solution should read input from standard input (stdin) and output the results for each operation to standard output (stdout), with each operation's result printed on a new line.
The following mathematical conditions must hold: \[ \text{For a valid deposit: } amount > 0, \quad \text{and for a valid withdrawal: } 0 < amount \leq balance. \]
inputFormat
The first line contains an integer T
(T ≥ 1), representing the total number of operations. Each of the following T
lines describes an operation in one of the following formats:
CREATE account_number pin
DEPOSIT account_number amount pin
WITHDRAW account_number amount pin
BALANCE account_number pin
outputFormat
For each operation, output the result on a new line. For CREATE
, output True
if the account was successfully created, otherwise False
. For DEPOSIT
and WITHDRAW
, output True
if the operation succeeded, otherwise False
. For BALANCE
, output the account's current balance or Invalid PIN
if the PIN is incorrect.
3
CREATE 123456 54321
DEPOSIT 123456 100 54321
BALANCE 123456 54321
True
True
100
</p>