编程介的小学生 2019-11-20 17:58 采纳率: 20.5%
浏览 85

On-Line Banking 编写的技术

Problem Description
A central bank is an institution that is responsible for the monetary policy of a country. Beside others, it monitors and supervises other banks. Your task is to write a computer program that will serve as a simple supervision instrument for monitoring bank accounts.

Input
The input contains several scenarios. Each scenario begins with a line containing a single positive integer A, the number of bank accounts at the beginning of the supervision, 0 < A ≤ 100. Then there are A lines each describing one account. Such a line contains the account number, one space, and a non-negative decimal number specifying the account balance.

Each of the following lines specifies a request for one bank operation. The line begins with a command and then, separated by a space, there are optional parameters. The list of commands follows, the third column in the table shows the number of parameters.

The number of requests in every scenario will always be between 0 and 1000 (inclusive). The last request of a scenario is followed by the word "end" and one empty line. Then the next scenario begins. The last scenario is followed by a line containing zero in place of A.

All account numbers consist of exactly four decimal digits followed by a slash character ("/") and one digit specifying a code of the bank that operates the account. Each bank has its own unique code.

Amounts are always given as non-negative decimal numbers with exactly two digits after the decimal point. No amount in the input will be higher than 10 000. No unnecessary leading zeros are permitted, i.e., only amounts strictly less than 1.00 may start with a zero.

Output
For each request, output exactly one line. The line must begin with the command followed by the amount parameter (if present) separated from the command by a space. Then there is a colon (":"), one space and the result of the operation.

create: If there is already an account with the same number in the same bank, the result will be "already exists". Otherwise, create the account (with the initial balance of zero) and output "ok".

For all commands other than create, if there is no account with the number specified as a parameter, the result will always be "no such account". If the account exists (or both accounts do), the following rules apply.

deposit: The result is always "ok" for existing accounts. Simply add the amount to the account balance.

withdraw: If the balance of the specified account is strictly lower than the requested amount, the result will be "insufficient funds". Otherwise, subtract the amount and output "ok".

transfer: First, if both account numbers are equal (including the bank code), the result should be "same account". Similar to the previous case, if the balance of the source account is lower than the amount to be transferred, the result will be "insufficient funds". Otherwise, transfer the money from the source account to the target one and output either "ok" if the transfer happens inside one bank or "interbank" if the money have to be transferred from one bank to another.

After each scenario, output the word "end" and one empty line. After the "end" of the last scenario, output one additional line containing the word "goodbye".

Sample Input
3
1234/5 100.00
4321/6 150.20
5432/5 1600.00
withdraw 1234/5 20.00
deposit 1234/5 35.00
withdraw 1234/5 200.00
transfer 5432/5 1234/5 100.50
transfer 5432/5 4321/6 50.00
create 1234/5
create 1236/5
transfer 1236/5 1236/5 100.00
transfer 1236/5 1234/5 100.00
withdraw 0000/0 100.00
deposit 0000/0 0.11
transfer 1234/5 0000/0 10000.00
end

1
9999/9 9.40
deposit 9999/9 6.92
withdraw 9999/9 9.68
withdraw 9999/9 6.64
end

0

Sample Output
withdraw 20.00: ok
deposit 35.00: ok
withdraw 200.00: insufficient funds
transfer 100.50: ok
transfer 50.00: interbank
create: already exists
create: ok
transfer 100.00: same account
transfer 100.00: insufficient funds
withdraw 100.00: no such account
deposit 0.11: no such account
transfer 10000.00: no such account
end

deposit 6.92: ok
withdraw 9.68: ok
withdraw 6.64: ok
end

goodbye

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥200 uniapp长期运行卡死问题解决
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
    • ¥15 乘性高斯噪声在深度学习网络中的应用
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决