- 分享
- 0
- 人气
- 0
- 主题
- 51
- 帖子
- 893
- UID
- 163526
- 积分
- 1336
- 阅读权限
- 18
- 注册时间
- 2008-8-30
- 最后登录
- 2015-2-16
- 在线时间
- 2325 小时
|
1. Write a program that helps you balance your bank account. This interactive program should read a list of transaction amounts. (The first transaction amount should be the beginning balance). The program should then display the transactions, along with a running balance. At the end of the transactions, the program should display the total number of deposits (less 1), the total of all the deposits (other than the first one), the total number of withdrawals, and the total of all the withdrawals. Here’s an example of the program in use:
*** Bank Balance Helper ***
Enter beginning balance: 100
Transaction 1 (0 to end): 200
Transaction 2 (0 to end): -50
Transaction 3 (0 to end): 20.75
Transaction 4(0 to end): 0
*** Transaction Report ***
Beginning balance is 100
Transaction 1: Deposit 200, giving balance of 300
Transaction 2: Withdrawal of 50, giving balance of 250
Transaction 3: Deposit of 20.75, giving balance of 270.75
Number of deposits: 2
Total deposits: 220.75
Number of withdrawals: 1
Total withdrawals: 50
Current Balance: 270.75
Make the array hold exactly 10 floating-point numbers (This includes the beginning values). If the array fills, the program should automatically display the transaction report. If the balance goes below zero, display a warning message for that transaction, but allow the balance to be negative.
hint: Make an array size of 10 to store the every transaction data, use the do_while or other loop to ask users prompt the input. Then create three method
for deposit, withdrawal and also display report. The report will be display whenever user enter 0 or user has made 10 times transactions. |
|