Skip to content

sabamadadi/ATM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

🏦 ATM Operations Guide

This guide explains the commands and behaviors of an ATM system.

REGISTER

Input Format:

REGISTER USERNAME TIMESTAMP

Explanation:

A user with the name USERNAME registers in the ATM at the TIMESTAMP.

Output:

  • Registered Successfully — if the user is registered for the first time.
  • ⚠️ Duplicate User! — if the user already exists.

DEPOSIT

Input Format:

DEPOSIT USERNAME AMOUNT TIMESTAMP

Explanation:

The amount of AMOUNT currency is added to the account of the user with the name USERNAME at the TIMESTAMP.

Output:

  • ✅ Current balance after deposit.
  • ⚠️ No Such User Found! — if the user does not exist.

WITHDRAW

Input Format:

WITHDRAW USERNAME AMOUNT TIMESTAMP

Explanation:

The amount of AMOUNT currency is withdrawn from the account of the user with the name USERNAME at the TIMESTAMP, and for that amount, the equivalent amount of currency is deducted from the banknotes inside the ATM.

Output:

  • ✅ Current balance after withdrawal.
  • ⚠️ No Such User Found! — if the user does not exist.
  • ⚠️ Maximum Amount Exceeded! — if AMOUNT > 200.
  • ⚠️ Not Enough Fund! — if user balance < AMOUNT.
  • ⚠️ Not Enough Banknotes! — if the ATM cannot dispense the requested amount using available banknotes.

TRANSFER

Input Format:

TRANSFER SENDER_USERNAME RECEIVER_USERNAME AMOUNT TIMESTAMP

Explanation:

The amount of AMOUNT currency is withdrawn from the account of the user with the name SENDER_USERNAME at the TIMESTAMP, and exactly one hour after that, it is deposited into the account of the user with the name RECEIVER_USERNAME.

Output:

  • ✅ Current balance of sender after transfer.
  • ⚠️ No Such User Found! — if either user does not exist.
  • ⚠️ Maximum Amount Exceeded! — if AMOUNT > 3000.
  • ⚠️ Not Enough Fund! — if sender's balance < AMOUNT.

GET_BALANCE

Input Format:

GET_BALANCE USERNAME TIMESTAMP

Explanation:

At the TIMESTAMP, the balance of the account of the user with the name USERNAME is printed, and 10 currency units are deducted from that account.

Output:

  • ✅ Balance after deducting 10 units.
  • ⚠️ No Such User Found! — if the user does not exist.
  • ⚠️ Not Enough Fund! — if balance < 10.

ADD_BANKNOTE

Input Format:

ADD_BANKNOTE VALUE AMOUNT TIMESTAMP

Explanation:

At the TIMESTAMP, each of the AMOUNT banknotes with the VALUE value is added to the banknotes inside the ATM.

It is guaranteed that the VALUE is one of the values of 1, 5, 10, 50, or 100.

Output:

  • ✅ Total assets of the ATM after adding the banknotes.

Notes:

  • After registration, each user's initial account balance is 100 currency units.
  • The DEPOSIT command does not add anything to the banknotes inside the ATM.
  • In the WITHDRAW command, the ATM delivers the minimum number of banknotes if it pays the amount.
  • Initially, the ATM has 10 banknotes of each of the denominations of 1, 5, 10, 50, and 100.
  • It is guaranteed that the format of all TIMESTAMPS is YYYY/MM/DD-hh:mm:ss, where YYYY, MM, DD, hh, mm, and ss represent the year, month, day, hour, minute, and second of the operation, respectively. Also, all TIMESTAMPS have a valid value.
  • All USERNAMES consist only of lowercase English letters and are at most 10 characters long.
  • In each section, if more than one error occurs, consider the first error as the output.
  • Commands are executed in order of TIMESTAMPS.

Input:

The input contains at most 200 lines. The first line contains a number n, indicating the number of commands given. Then in the next n lines, each line contains one of the valid commands.

It is guaranteed that the format of the input commands is as specified, and also no two operations have the same TIMESTAMP. (Including deposits to the account in the TRANSFER operation)

Output:

  • ✅ For each command given in the input, print the appropriate output on a separate line in order.

About

We want to simulate an ATM that supports various operations!

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages