"C + + Chapter fifth personal bank Account management procedures case"

Source: Internet
Author: User

"Fifth chapter" personal Bank Account management procedure case Realization
5_11.cpp#include "Account.h" #include <iostream> #include "account.cpp" using namespace Std;int Main () {// Establish several accounts SavingsAccount sa0 (1, 21325302, 0.015); SavingsAccount SA1 (1, 58320212, 0.015);//Several accounts sa0.deposit (5, 10000); Sa1.deposit (45, 5500); Sa1.withdraw (60, 4000);//The 90th day after the opening of the account to the bank's interest date, the settlement of all accounts of the annual Sa0.settle (90);//output each account information sa0.show (); cout << endl;sa1.show (); cout << endl;cout << "total:" << savingsaccount::gettotal () << Endl;return 0;}

  

1 //Account.cpp:Defines the entry point for the console application.2 3 4 5 #ifndef _account_h_6 7 #define_account_h_8 9 classSavingsAccount//Savings Account CategoryTen  One { A  - Private: -  the     intId//Account Number -  -     DoubleBalance//Balance -  +     DoubleRate//Annual interest rate of deposit -  +     intLastdate;//date when the balance was last changed A  at     Doubleaccumulation;//the balance is compounded by daily -  -     Static DoubleTotal//Total amount for all accounts -  -                          //record an account, date is dated, desc is a description -  in     voidRecordintDateDoubleamount); -  to     //earn a daily cumulative value for the deposit amount up to the specified date +  -     DoubleAccumulate (intDateConst the  *     { $ Panax Notoginseng         returnAccumulation + balance* (date-lastdate); -  the     } +  A  Public: the  +     //constructor Function -  $SavingsAccount (intDateintIdDoubleRate ); $  -     intGetId ()Const{returnID;} -  the     DoubleGetBalance ()Const{returnbalance;} - Wuyi     DoubleGetrate ()Const{returnRate ;} the  -     Static DoubleGettotal () {returnTotal ;} Wu  -     voidDepositintDateDoubleAmount);//Cash Deposit About  $     voidWithdraw (intDateDoubleAmount);//Withdraw Cash -  -                                             //settle interest, which is called once every January 1 of the function -  A     voidSettleintdate); +  the     //Show account Information -  $     voidShow ()Const; the  the }; the  the #endif//_account_h_
1 //Account.cpp2 3#include"account.h"4 5#include <cmath>6 7#include <iostream>8 9 using namespacestd;Ten  One DoubleSavingsaccount::total =0; A  - //implementation of SavingsAccount class-related member functions -  theSavingsaccount::savingsaccount (intDateintIdDoubleRate ) -  -: ID (ID), balance (0), Rate, lastdate (date), accumulation (0) -  + { -  +cout << Date <<"\t#"<< ID <<"is created"<<Endl; A  at } -  - voidSavingsaccount::record (intDateDoubleamount) -  - { -  inaccumulation =accumulate (date); -  toLastdate =date; +  -Amount = Floor (amount * -+0.5) / -;//keep two digits after the decimal point the  *Balance + =amount; $ Panax NotoginsengTotal + =amount; -  thecout << Date <<"\t#"<< ID <<"\ t"<< Amount <<"\ t"<< Balance <<Endl; +  A } the  + voidSavingsAccount::d eposit (intDateDoubleamount) -  $ { $  - Record (date, amount); -  the } - Wuyi voidSavingsaccount::withdraw (intDateDoubleamount) the  - { Wu  -     if(amount>getbalance ()) About  $cout <<"Error:not enough money"<<Endl; -  -     Else -  ARecord (date,-amount); +  the } -  $ voidSavingsaccount::settle (intdate) the  the { the  the     DoubleInterest = accumulate (date) *rate/365;//calculate the interest per annum -  in     if(Interest! =0) the  the Record (date, interest); About  theaccumulation =0; the  the } +  - voidSavingsaccount::show ()Const the Bayi { the  thecout <<"#"<< ID <<"\tbalance:"<<balance; -  -}

Ps:

Supporting materials: PhD "C + + programming language"

Course: the Academy Online "C + + programming language"

"C + + Chapter fifth personal bank Account management procedures case"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.