C++作业04

原创 2004年10月26日 12:20:00

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.

java第三周作业,第一个

因为在电脑室就完成了.于是保存成图片形式,上传了~
  • u013928481
  • u013928481
  • 2014年03月19日 22:01
  • 375

解答C++作业04

//ChkgAcct.h//ChkgAcct classes#ifndef CHKGACCT_H#define CHKGACCT_Hclass ChkgAcct {  public:    ChkgA...
  • skyinter
  • skyinter
  • 2004年10月26日 12:27
  • 665

帮同学写的C++大作业,图书管理系统

#include #include #include #include #include #include #include #include #include #include #define de...
  • zhoujinyu0713
  • zhoujinyu0713
  • 2012年12月12日 23:24
  • 3004

2013年大一上学期的C++大作业 学生信息管理系统

main.cpp #include #include #include #include "function.h" using namespace std; int main() { p...
  • u012725244
  • u012725244
  • 2015年04月11日 19:47
  • 1568

C++期末大作业

实现一个工资管理系统 一、内容 1.题目《小型公司工资管理系统》设计 2.设计说明与要求 (1) 公司主要有5类人员:文秘、技术经理、技术员、销售员、销售经理。要求存储这些...
  • u013928645
  • u013928645
  • 2014年06月21日 20:57
  • 1503

C++期末作业

    好无聊的 C++作业,虽然是练熟练度的,但是好歹也出个有点意思的题目吧... #include /*关于运算符重载,完全定义六个类之间的四则运算实在是太耗费时间了,只定义了 圆加上...
  • ypc1109
  • ypc1109
  • 2010年11月30日 19:57
  • 556

C++课程设计作业

4、模拟智能交通信号灯系统  设计一个智能信号灯系统,在十字路口控制东西南北四个方向交通信号,当然是红灯停绿灯行了, 一般情况是四个方向每次绿灯亮30秒,只不过在绿灯熄灭后亮3秒黄灯再转红...
  • u014042940
  • u014042940
  • 2014年06月11日 15:32
  • 985

第二周C++作业

实验作业 1.编写调式运行第一个C++程序,要求输出你的班级、姓名和学号;#include using namespace std; int main() { cout...
  • u013928960
  • u013928960
  • 2014年03月14日 22:54
  • 466

21天学通C++之对象作业实战

因为作者平时不使用C++进行编程,但是课程刷分无奈又学习一遍,这样其实只要跟随老师的脚步一步一步进行学习和实验就可以了(ps:第一次没好好学,只拿了73分)。所以初期关于C++的学习大多OJ编程作业上...
  • qq_24052051
  • qq_24052051
  • 2017年03月17日 13:42
  • 290

短作业优先算法c++版

 #include "stdafx.h" #include "iostream" #include "string" using namespace std; struct JOB//作...
  • cherish_CX
  • cherish_CX
  • 2016年11月21日 22:49
  • 1942
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:C++作业04
举报原因:
原因补充:

(最多只允许输入30个字)