当前位置: 首页>>代码示例>>C++>>正文


C++ BankAccount类代码示例

本文整理汇总了C++中BankAccount的典型用法代码示例。如果您正苦于以下问题:C++ BankAccount类的具体用法?C++ BankAccount怎么用?C++ BankAccount使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BankAccount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: on_withdraw_clicked

void BankWithdraw::on_withdraw_clicked()
{
    double amount = ui->inputmoney->text().toDouble();
    BankAccount *bac = new BankAccount;
    bool ifwithdraw;
    ifwithdraw = bac->withdrawlMoney(amount);
    QMessageBox *deposit = new QMessageBox;
    if(ifwithdraw){
        deposit->setText( "Successfully Withdraw $ "+ ui->inputmoney->text());    //("Deposit", "Successfully Deposit $ "+ ui->inputmoney->text());

    }else{
        deposit->setText("Withdraw Fail!");
    }
    deposit->show();
    bac->~BankAccount();
}
开发者ID:cctv2206,项目名称:web-app-stock-forecasting-system,代码行数:16,代码来源:BankWithdraw.cpp

示例2: main

int main()
{
	string symbol;			// company stock symbol
	double val;				
	double cashBal;			// variable for cashBalance
	int choice;				// user choice	
	const int def = 10000;	// default cashBalance value
	int numOfShares;		// stock number of shares
	double maxPrice;		// max price user is willing to pay to buy stock
	double minPrice;			// min price user is willing to pay to sell stock
	double totalBal;

	BankAccount ba;		// create object of class BankAccount
	double am;			// declare amount variable which will be used by class BankAccount

	StockPortfolioAccount spa;		// create object of class Stock Portfolio Account

	DoublyLinkedList dll;			// create  dll

	time_t t;			// create a time_t object
	struct tm  buf;		// create a tm object which stores all the calendar information


	//------------------------ Step 1 - load the stock text file data into hash table-----------------------------


	loadFile();


	// -----------------------Step 2 - Load the cashBalance value from .txt file-----------------------------------
	{	// start of block statement

		ifstream inCash("cash_balance.txt");						// create ifstream object
		ofstream cas;

		if (inCash.good())	// if file exists
		{
			//inCash.open("cash_balance.txt", ios::in);		// open the file
			getline(inCash, line);					// get the line
			stringstream ss(line);					// store it in stringstream
			ss >> cashBal;							// retireve the cashBalance
			ba.setBalance(cashBal);					// set the cashBalance
			inCash.close();
		}
		// if file is not created then create a new cash_balance.txt file and store 10000
		else
		{
开发者ID:aadityashukla1,项目名称:Stock-and-Bank-Account-Management-System,代码行数:47,代码来源:main_aaditya.cpp

示例3: deposit

void deposit(BankAccount account[], int num_accts){
    int accountnum = 0;
    accountnum = accountNumPrompt();
    accountnum = find_acct(account, num_accts, accountnum);
    if(accountnum == -1){
        string message = "We couldn't find an account by that number";
        error(message);
        deposit(account, num_accts);
    }else{
        BankAccount * b = &account[accountnum];
        double howmuch = 0.00;
        cout << endl << "How much do you want to deposit?" << endl;
        cin >> howmuch;
        b->addAccountBalance(howmuch);
        cout << endl << howmuch << " has been deposited int account: " << b->getAccountNumber() << endl;
    }
}
开发者ID:stephonlawrence,项目名称:Simple-Console-Bank,代码行数:17,代码来源:main.cpp

示例4: QWidget

BankHis::BankHis(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::BankHis)
{
    ui->setupUi(this);

    QPixmap pix = QPixmap("img.jpg").scaled(this->size());
    QPalette pal(this->palette());
    pal.setBrush(QPalette::Background,QBrush(pix));
    this->setPalette(pal);
    this->setWindowOpacity(0.9);

    BankAccount *bac = new BankAccount;// = new BankAccount;
    QString hist = QString::fromStdString(bac->printHistory());
    QLabel *his = new QLabel(hist);
    ui->s->setWidget(his);

    bac->~BankAccount();
}
开发者ID:cctv2206,项目名称:web-app-stock-forecasting-system,代码行数:19,代码来源:BankHis.cpp

示例5: find_acct

int find_acct(BankAccount account[], int num_accts, int request_acct){
    //creats pointer variable
    BankAccount * b;
    int num = 0;
    //bool for telling when we have found the right account
    bool found = false;
    for(int i=0; i<num_accts; i++){
        //store current account
        b = &account[i];
        if(b->getAccountNumber() == request_acct){
            //store account number when it matches the requested number
            num = i;
            found = true;
            break;
        }
    }
    if(found){
        return num;
    }else{
        return -1;
    }
}
开发者ID:stephonlawrence,项目名称:Simple-Console-Bank,代码行数:22,代码来源:main.cpp

示例6: newAccount

int newAccount(BankAccount account[], int max_accounts, int num_accts){
    BankAccount * b;
    //make sure there is space left
    if(num_accts+1 <= max_accounts){
        b = &account[num_accts];
        string fname, lname, type;
        int SSN;
        double acctbalance;
        cout << endl << "Please enter first name: ";
        cin >> fname;
        cout << endl << "Please enter last name: ";
        cin >> lname;
        cout << endl << "Please enter SSN (Social Security Number): ";
        cin >> SSN;
        cout << endl << "Please enter Account Type: ";
        cin >> type;
        cout << endl << "Please enter Account starting Balance: ";
        cin >> acctbalance;
        b->setFirstName(fname);
        b->setLastName(lname);
        b->setSSN(SSN);
        //increment the account number
        int greatest = 0;
        BankAccount * g;
        for(int i=0; i < num_accts; i++){
            g = &account[i];
            if(g->getAccountNumber() > greatest){
                greatest = g->getAccountNumber();
            }
        }
        greatest++;
        b->setAccountNumber(greatest);
        b->setAccountType(type);
        b->setAccountBalance(acctbalance);
        num_accts++;
        return num_accts;
    }
开发者ID:stephonlawrence,项目名称:Simple-Console-Bank,代码行数:37,代码来源:main.cpp

示例7: print_accts

void print_accts(BankAccount account[], int num_accts){
    //create pointer variable
    BankAccount * b;
    for(int i=0; i<num_accts; i++){
        //stores our current account
        b = &account[i];
        cout << "name: " << b->getFirstName() << " " << b->getLastName() << endl;
        cout << "\t\tAccount Number: " << b->getAccountNumber() << endl;
        cout << "\t\tAccount Type: " << b->getAccountType() << endl;
        cout << "\t\tAccount Balance: " << b->getAccountBalance() << endl;
    }
}
开发者ID:stephonlawrence,项目名称:Simple-Console-Bank,代码行数:12,代码来源:main.cpp

示例8: main

int main()
{
	using namespace Bank_Account;
	BankAccount Gavrila = BankAccount("Ivan Ivanov", "12345678q", 10000);
	std::cout << "Hello, let me tell you about myself" << std::endl;
	Gavrila.show();
	std::cin.get();
	std::cout << "One day I suddenly understood that someone accidently give me some cash. Look" << std::endl;
	std::cin.get();
	Gavrila.add_money(500);
	Gavrila.show();
	std::cin.get();
	std::cout << "I was so happy, that I started to buy expensive things" << std::endl;
	std::cin.get();
	std::cout << "Like this cat =^.^=" << std::endl;
	std::cin.get();
	Gavrila.retrieve_money(300);
	std::cin.get();
	std::cout << "Like these flowers @>--;-- @>--;-- @>--;-- @>--;--" << std::endl;
	std::cin.get();
	Gavrila.retrieve_money(500);
	std::cin.get();
	std::cout << "Like this bear (''')-.-(''')" << std::endl;
	std::cin.get();
	Gavrila.retrieve_money(8000);
	std::cin.get();
	std::cout << "And these pretty cats >^..^<   >'o'<   >^..^<" << std::endl;
	std::cin.get();
	Gavrila.retrieve_money(3000);
	std::cin.get();
	std::cout << "And finally I got broken" << std::endl;
	std::cin.get();
	Gavrila.show();
	std::cin.get();
	std::cout << "Sad story =(" << std::endl;
	return 0;
}
开发者ID:Zaytceva,项目名称:cpp.fundamentals,代码行数:37,代码来源:main.cpp

示例9: main

void main()
{
	BankAccount b;
	b.setName("Rana");
	b.setAccount("234");
	b.setBalance(20);
	b.deposite(1024);
	b.deposite(1024);
	cout<<b.getBalance();
	system("pause");


}
开发者ID:RanaSamy,项目名称:Assignment1,代码行数:13,代码来源:Source.cpp

示例10: main

int main ()
{
    BankAccount one{"Fist one", "Three hundre", 300};
    BankAccount two = BankAccount("Second two", "zero");
    BankAccount three = BankAccount();
    one.show();
    one.deposit(500);
    two.show();

    three = BankAccount("one million", "one million", 100000);
    three.show();
    three.withdraw(7852);
    three.show();
    one.show();
    return 0;
}
开发者ID:aoitori,项目名称:learning,代码行数:16,代码来源:10im.cpp

示例11: read_accts

//Account Functions --------------------------------------------------------------------------------------------------------
int read_accts(BankAccount account[], int max_accounts){
    //start counter
    int count = 0;
    //temporary variables
    string fname, lname, type;
    int SSN;
    double acctbalance;
    //count how moany entries are in the file.
    while(!File.eof() && count < max_accounts){
        File >> fname >> lname >> SSN >> type >> acctbalance;

        count++;
    }
    //loop back to top of file.
    File.clear();
    File.seekg(0, ios::beg);
    //counter for our current account
    int i = 0;
    //create pointer for changing the values at the direct address in memory
    BankAccount * b;
    //loop trhough file and save and set values
    while(!File.eof() && i < count){
        //set our current account into our pointer variable
        b = &account[i];
        //define our file format
        File >> fname >> lname >> SSN >> type >> acctbalance;
        //set all of our values
        b->setFirstName(fname);
        b->setLastName(lname);
        b->setSSN(SSN);
        b->setAccountNumber(i);
        b->setAccountType(type);
        b->setAccountBalance(acctbalance);
        i++;
    }
    return count;
}
开发者ID:stephonlawrence,项目名称:Simple-Console-Bank,代码行数:38,代码来源:main.cpp

示例12: getBankAccounts

void Client::Transfer(){
    int amountToTransfer;
    BankAccount* bcIncome = getBankAccounts();
    cout << endl << "Amount to transfer : " << endl;
    cin >> amountToTransfer;

    if(bcIncome->ConsultAmount()< amountToTransfer){
        cout << "Insufficient amount" << endl;
    }
    else{
        BankAccount* bcToTransfer = getBankAccounts();
        if(bcToTransfer->getId() != bcIncome->getId()) {
            bcIncome->Transfer(amountToTransfer, bcToTransfer);
            cout << *bcIncome << endl;
        }
        else{
            cout << "The two accounts must be different"<<endl;
        }
    }
}
开发者ID:AdrienPoupa,项目名称:banking-system,代码行数:20,代码来源:Client.cpp

示例13: mainMenu

void mainMenu()
{
    int mainChoice; // choice for top menu
    
	// stockaccount object
	StockAccount stockObj;
	// bankaccount object
	BankAccount bankObj;

	// link two balance
	bankObj.setBalance(stockObj.getBalance());

    do {
        instructionTop();
        cin >> mainChoice;
		while (cin.fail()){
			cout << "\nPlease enter an integer value: ";
			cin.clear();
			cin.ignore();
			cin >> mainChoice;
		}

        switch ( mainChoice ) {
            case 1:
            {
                // stock menu
                cout << "\nStock Portfolio Account" << endl;

				// update balance
				stockObj.setBalance(bankObj.getBalance());

                int stockChoice; // choice for stock menu
                
                string stockSymbol; // stock symbol
                int numberShare; // number of shares
                double maxPrice; // max price to buy shares
                double minPrice; // min Price to sell shares
				string time_start, time_end; // time period to view graph
                
                do {
                    stockInstruction();
                    cin >> stockChoice;

					while (cin.fail()){
						cout << "\nPlease enter an integer value: ";
						cin.clear();
						cin.ignore();
						cin >> stockChoice;
					}

                    //StockAccount *stockPtr = &account;
                    
                    switch ( stockChoice ) {
                        case 1:
                            // display price for stock
                            cout << "\nPlease enter the stock symbol: ";
                            cin >> stockSymbol;
                            stockObj.displayPrice( stockSymbol ); // WORKING ON IT
                            break;
                        case 2:
                            // display current portfolio
                            //cout << "display current portfolio" << endl;
							stockObj.displayPortfolio();
                            break;
                        case 3:
                            // buy shares
                            cout << "Please enter the stock symbol you wish to purchase: ";
                            cin >> stockSymbol;
							
                            cout << "Please enter the number of shares: ";
                            cin >> numberShare;
							while (cin.fail()){
								cout << "\nPlease enter an integer value: ";
								cin.clear();
								cin.ignore();
								cin >> numberShare;
							}

                            cout << "Please enter the maximum amount you are willing to pay per share: $";
                            cin >> maxPrice;
							while (cin.fail()){
								cout << "\nPlease enter a double value: $";
								cin.clear();
								cin.ignore();
								cin >> maxPrice;
							}

							stockObj.buyStock(&Node(stockSymbol, numberShare), maxPrice);
                            
                            break;
                        case 4:
                            // sell shares
                            cout << "Please enter the stock symbol you wish to sell: ";
                            cin >> stockSymbol;
                            cout << "Please enter the number of shares: ";
                            cin >> numberShare;

							while (cin.fail()){
								cout << "\nPlease enter an integer value: ";
								cin.clear();
//.........这里部分代码省略.........
开发者ID:LishengZhou,项目名称:AccountManagementSystem,代码行数:101,代码来源:Main_zhou.cpp

示例14: main

int main() {
	BankAccount A;
	A.Initialize("Waseem Hassan", 234, "Savings", 20000);
	return 0;
}
开发者ID:theplaymate,项目名称:C---Programs,代码行数:5,代码来源:CP+Lab+Tasks+7.cpp

示例15: ATMWithdrawal

void ATMWithdrawal(BankAccount& acct, int sum) {
    lock_guard<BankAccount> guard(acct);
    acct.Withdraw(sum);
    acct.Withdraw(2);
}
开发者ID:viboes,项目名称:synchro,代码行数:5,代码来源:IL_Rec_Lockable_BancAccount.cpp


注:本文中的BankAccount类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。