一个简单的java试题,求解

2013-05-17 19:43:52 +08:00
 Insomnia
题目要求如下:

Write a program named bank that maintains a database of bank accounts. Each account will be stored in a BankAccount object. The Following example shows what the user will see:
commands:

-------------------------------------------------

| Commands: o - Open account c - Close account|

| d - Deposit w - Withdraw |

| s - Select account q - Quit |

-------------------------------------------------

Current account: None selected



Enter command: o

Enter new account number: 158-740

Enter initial balance: 250



-------------------------------------------------

|Commands: o - Open account c - Close account|

| d - Deposit w - Withdraw |

| s - Select account q - Quit |

-------------------------------------------------

Current account: 158-740 Balance: 250.00


Enter command:

The program repeatedly prompts the user to enter commands, which it then executes. The program will not terminate until the user enters the command q. Note that the list of commands is redisplayed after each command has been executed, along with the current access and its balance. If there is not current account, the message

None selected
is displayed instead of the account number.


Commands Documentation:


Open account: The user is prompted to enter a new account number and initial balance. This data is stored in a new BankAccount object. BankAccount objects for all the existing accounts must be stored in an array. The new account becomes the current account.


Close account: If there is no current account, the message
Please select an account
is displayed. Otherwise, the current account is closed. There is no current account after this operation is completed.

Deposit: If there is no current account, the message
Please select an account
is displayed. Otherwise the user is promoted to enter the amount of the deposit:
Enter amount to deposit: 100
The amount entered by the user is added to the balance of the current account.

Withdraw: If there is no current account the message
Please select an account
is displayed. Otherwise the user is promoted to enter the amount of the withdrawal
Enter amount to withdraw: 25
The amount entered by the user is subtracted to the balance of the current account.

Select account: The user is prompted to enter an account number
Enter account number: 158-740

The array is then searched to see if any BankAccount object contains this number. If, so, that object becomes the current account. If not, the following message is displayed
Account number was not found

Quit: Terminate program.


Few other requirements for the program:

The size of array used to store BankAccount objects must be 20 elements.
Add sufficient comments to your code.
Follow Java indentation rules.



不知道谁能帮忙给写下这个代码。。。也不知道该如何感谢,只能先用这里的金币来感谢了。
希望可以得到帮助。谢谢了先。
5270 次点击
所在节点    Java
56 条回复
vibbow
2013-05-17 19:47:22 +08:00
看起来挺像面试题的。
读懂了的话其实很简单......
Kymair
2013-05-17 19:58:56 +08:00
同学你这是比较明显的求代做作业啊… 这样不太好。实在要这样,还是去CSDN吧 =_=
ljbha007
2013-05-17 20:06:24 +08:00
呵呵 呵呵 呵呵
最讨厌叫人代做作业的了 完完全全的诈骗还不知廉耻
Insomnia
2013-05-17 20:57:49 +08:00
@vibbow 不是面试题,是一个朋友发给我的,让我帮他写一下。可是我只会 PHP。

@Kymair 谢谢。我先尝试下,实在不行再去 CSDN 问。
Insomnia
2013-05-17 21:00:13 +08:00
@ljbha007 谁他妈的诈骗了? 诈骗个JB,我又没编个理由出来,怎么诈骗了? 你TMD还有脸说廉耻二字,你上来就说我诈骗,你的廉耻呢?

能帮就帮,不能帮就不帮。至于上来给我回个这个吗?
ljbha007
2013-05-17 21:17:55 +08:00
@Insomnia
你叫人帮你写代码的目的肯定是要把这个代码拿去交差,如果你拿别人的代码去交差,必然会欺骗接收方说这个代码是你自己写的。

按照诈骗的定义:
fraud is intentional deception made for personal gain or to damage another individual

https://en.wikipedia.org/wiki/Fraud

你欺骗这个代码的接收方说这个代码是你写的,并从中为自己获取利益(比如 完成作业、通过面试),那么你就是完完全全符合诈骗的定义

我并没有血口喷人
ljbha007
2013-05-17 21:19:54 +08:00
@Insomnia
我并没有血口喷人
仅仅是你没有意识到问题的严重性而已
ljbha007
2013-05-17 21:27:51 +08:00
@Insomnia
如果你是帮你朋友写的 并且他希望通过这个代码获取某种利益(比如 完成作业、通过面试),他同样是在诈骗,并且你也是在参与诈骗
b1074549
2013-05-17 23:38:26 +08:00
作弊的竟然跑到这来了
gzb1985
2013-05-17 23:42:43 +08:00
@Insomnia 哥们,淡定淡定,求人一时,不能一世,还是自己动手,丰衣足食啊。
支持 @ljbha007 君。
evanmeng
2013-05-17 23:54:45 +08:00
每年總有那麼幾個月,到處都會有這種叫別人寫作業的貼子的……習慣就好。
liprais
2013-05-18 00:03:13 +08:00
已block楼主,同时感谢@ljbha007
mantianyu
2013-05-18 00:19:12 +08:00
太长不爱看。。。。。
best1a
2013-05-18 00:21:13 +08:00
@ljbha007 “你叫人帮你写代码的目的肯定是要把这个代码拿去交差”,请求这句话的判断的依据,这句话不成立的话,你下面说的话没有任何意义

ps:反感代做作业是一回事,根据一个帖子然后就进行诡异的逻辑判断是另一回事
ljbha007
2013-05-18 00:37:25 +08:00
@best1a
一点也不诡异 我前面说的很清楚 就是为了自己利益(帮朋友忙)欺骗别人(代码的接收方),这就是欺诈
ljbha007
2013-05-18 00:37:38 +08:00
@best1a 诈骗
best1a
2013-05-18 00:38:39 +08:00
@ljbha007 请问代码的接收方是谁?
ljbha007
2013-05-18 00:41:52 +08:00
@best1a
不知道
但是根据楼主的要求可以很清楚的推断出他是要把这个代码当成他自己的或者他朋友的拿来交给对方
所以诈骗的行为肯定是没的跑的(如果这么做了的话)
zack119
2013-05-18 00:48:11 +08:00
oschina里搜atm看看
best1a
2013-05-18 00:50:26 +08:00
@ljbha007 有意思的推断。为何你不考虑这种情况呢:某个人在网上看到一道面试题,不太明白,然后问朋友呢

根据google出的结果,可以发现一道类似的题,http://www.chegg.com/homework-help/questions-and-answers/write-program-named-bank-maintains-database-bank-accounts-account-stored-bankaccount-objec-q1592446

其分类在homework help下面,个人根据题目分隔来推测,感觉更像作业,也符合你的判断。然后,即使是作业的话,也有N种可能,懒得说了,如果你要怀着别人就是欺骗XXX而XXX的想法话,我也没话说。你以为你知道的就是真相么?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/69230

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX