编程语言

img skyinter

C++作业04

发表于2004/10/26 12:20:00  667人阅读

分类: Crazy Soul For C++


Banking with Class


This assignment is to write a banking program using objects. The ChkgAcct class should provide all the functionality as described below. A suggested definition for ChkgAcct is given below. Note that none of your member functions should perform any input ( from the keyboard ) or output ( to the screen ). The withdrawal functions should return a boolean to indicate successful/non-successful transaction.

You should also write a main program (a "client" for your class) that creates an array of 10 accounts (0..9). Then you should prompt the user for an account number (0..9). If the user enters a number in the range of 0..9, prompt for the transaction type (telling the user what their options are), then amount if necessary, and then prompt for the next account number. Allow the user to enter any account number out of the range (0..9) to quit the program. The client program should make sure that the user has entered a positive value. Part of the score for this project is for the user interface. All of your prompts should be clear.

A sample class declaration and sample member function are provided to help you get started. You will need to fully define each of the member functions. The examples below are not commented, make sure your submitted program is commented appropriately.
 

class ChkgAcct { 
	public: 
	  ChkgAcct(); 
	  void deposit(double amt); 
	  bool checkwithdraw(double amt); 
	  bool atmwithdraw(double amt); 
	  double getbalance(); 
	
	private: 
	  double balance;
}; 
  
  
ChkgAcct::ChkgAcct(){ 
    balance = 100.0; 
} 
  

Class ChkgAcct provides the following services (member function):

Deposit
Accepts as an argument the amount to be deposited. Increases the Balance by the deposited amount.

Checkwithdrawal
Accepts as an argument the amount to be withdrawn. If there are sufficient funds in the account to cover the amount requested, the amount requested is deducted from the balance. If there are insufficient funds a $10.00 service charge is deducted from the account instead.

ATMwithdrawal
This should work like a check, with two exceptions. First, a $1 service charge is deducted from the balance for each completed transaction. Second, If there are insufficient funds for the transaction, the transaction is not made and no service charges are deducted from the account.

CurrentBalance
Returns the balance.

Initialization (constructor)
All bank accounts should begin with $100.00. You should also initialize the appropriate variables to keep track of the transactions, if applicable.

NOTE: Accounts may go negative due to service charges.

EXTRA CREDIT:
Track the transactions on the account, so you can print a record showing the last (up to) 50
transactions on an account. If there were 55 transactions, then you should display the most recent 50 transactions.
 
Additional requirement:
For this assignment, divide your program into three files (two for the object(.cpp and .h)and one for main.)
The class definition goes in a header file, the class member function definition goes in a second file(.cpp), and the client code in a third file. If you are working in a visual project environment ( C++ Builder, Visual C++ ), you will need to add these additional files to your project.

Style: I will start to take off points for poor style in your code.

  • Think about making your code readable.
  • Avoid line wrap ( in almost all cases a line can be shorted so that it will not wrap around when it prints).
  • If possible, print your program from a developement environment (VC++, UltraEdit), because then the environment will show syntax highlighting in the printout. ( I will give a few extra points if you print from from an development environment).

Demo: You will demo your program for your lab instructor next week, so make sure you bring your files so you can run the program and a printout of the program to turn in during class.

阅读全文
0 0

相关文章推荐

img
取 消
img