#C14556. Banking System Simulation
Banking System Simulation
Banking System Simulation
You are required to implement a simple banking system that supports basic operations such as creating accounts, depositing funds, withdrawing funds, transferring funds between accounts, and applying a monthly interest.
Commands:
• CREATE username password: Create a new account. Output true
if successful, false
otherwise.
• DEPOSIT username password amount: Deposit the specified amount (a positive number) into the account. Output true
if successful, false
otherwise.
• WITHDRAW username password amount: Withdraw the specified amount from the account if the balance is sufficient. Output true
if successful, false
otherwise.
• TRANSFER username password amount target_username: Transfer the specified amount from one account to another. The transfer occurs only if the source account has sufficient funds and both accounts exist. Output true
if successful, false
otherwise.
• BALANCE username password: Output the current balance of the account as a floating-point number formatted with one decimal point.
• INTEREST: Apply a monthly interest of 1% to all accounts. After processing, print Interest applied
.
The interest is calculated using the formula: ( B_{new} = B + 0.01 \times B ).
All input is to be read from stdin
and all output should be written to stdout
.
inputFormat
The first line of input contains an integer (N) representing the number of commands. Each of the following (N) lines contains one command as described in the problem statement.
outputFormat
For each command that requires a response, output the result on a new line. Boolean values must be output as true
or false
, and numeric values must be printed as floating-point numbers (with one decimal point).## sample
6
CREATE user1 password
DEPOSIT user1 password 1000
BALANCE user1 password
WITHDRAW user1 password 500
BALANCE user1 password
WITHDRAW user1 password 600
true
true
1000.0
true
500.0
false
</p>