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();
}
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
		{
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;
    }
}
Exemple #4
0
void bankAgent()
{
    for (int i =10; i>0; --i) {
        //...
        JoesAccount.Deposit(500);
        //...
    }
}
Exemple #5
0
void Joe() {
    for (int i =10; i>0; --i) {
        //...
        int myPocket = JoesAccount.Withdraw(100);
        std::cout << myPocket << std::endl;
        //...
    }
}
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();
}
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;
    }
}
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;
    }
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;
    }
}
Exemple #10
0
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;
}
Exemple #11
0
void main()
{
	BankAccount b;
	b.setName("Rana");
	b.setAccount("234");
	b.setBalance(20);
	b.deposite(1024);
	b.deposite(1024);
	cout<<b.getBalance();
	system("pause");


}
Exemple #12
0
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;
}
//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;
}
Exemple #14
0
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;
        }
    }
}
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();
								cin.ignore();
								cin >> numberShare;
							}

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

							stockObj.sellStock(&Node(stockSymbol, numberShare), minPrice);
                            
                            break;
                        case 5:
                            // view matlab graph
							cout << "\nPlease select the time period in the graph: " << endl;
							cout << "Start Date (mm/dd/yyyy): ";
							cin >> time_start;
							cout << "\nEnd Date (mm/dd/yyyy): ";
							cin >> time_end;
							stockObj.viewGraph(time_start, time_end);
                            
                            break;
                        case 6:
                            // view transaction history
							stockObj.viewHistory();
                            
                            break;
                        
                    } // end stock switch
                } while ( stockChoice != 7 );
                
                break;
            } // end case 1
            case 2:
            {
                // bank menu
                cout << "\nBank Account" << endl;

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

                int bankChoice; // choice for bank menu
                
                double amount; // amount of money to deposit or withdraw
                
                do {
                    bankInstruction();
                    cin >> bankChoice;
                    
					while (cin.fail()){
						cout << "\nPlease enter an integer value: ";
						cin.clear();
						cin.ignore();
						cin >> bankChoice;
					}

                    switch ( bankChoice ) {
                        case 1:
                            // view account balance
                            
							bankObj.viewBalance();
                            break;
                        case 2:
                            // deposit
							
                            cout << "Please select the amount you wish to deposit: $";
                            cin >> amount;
							
							while (cin.fail()){
								cout << "\nPlease enter a double value: $";
								cin.clear();
								cin.ignore();
								cin >> amount;
							}
							
							bankObj.deposit(amount);
                            break;
                        case 3:
                            // withdraw
                            cout << "Please select the amount you wish to withdraw: $";
                            cin >> amount;
                            
							while (cin.fail()){
								cout << "\nPlease enter a double value: $";
								cin.clear();
								cin.ignore();
								cin >> amount;
							}
							bankObj.withdraw(amount);

                            break;
                        case 4:
                            // print history
							bankObj.printHistory();
                            
                            break;
                    } // end bank switch
                } while ( bankChoice != 5 );
                
                break;
            } // end case 2
        } // end main switch
    } while ( mainChoice != 3 );

}
int main() {
	BankAccount A;
	A.Initialize("Waseem Hassan", 234, "Savings", 20000);
	return 0;
}
void ATMWithdrawal(BankAccount& acct, int sum) {
    lock_guard<BankAccount> guard(acct);
    acct.Withdraw(sum);
    acct.Withdraw(2);
}
Exemple #18
0
int atm()
{
    CinReader reader;
    BankAccount myBanking;
    bool end_program = false;
    bool done = false;
    long dollars;
    int cents;
    do
    {
        cout << "Select the type of account you wish to create" << endl;
        cout << "1 Bank Account 2 - Checking 3 - Savings 4 - Credit\n" << endl;
        int choice = reader.readInt(1,4);
        string account_name;
        long balance_dollars;
        int balance_cents;
        double interest_rate;
        switch(choice)
        { 
            //Bank account options
            case 1:
            {
                cout << "Set the dollar amount of your account balance\n" << endl;
                balance_dollars = reader.readInt(0);
                cout << "Set the cent amount of your account balance\n" << endl;
                balance_cents = reader.readInt(0,99);
                myBanking.SetDollars(balance_dollars);
                myBanking.SetCents(balance_cents);
                cout << "Please select from the following options." << endl;
                while(!done)
                {
                    cout << "1 - Show account balance\n2 - Deposit\n3 - Withdraw\n4 - Show recent transactions\n5 - Clear Transaction history\n6 - Exit ATM\n" << endl;
                    int choice = reader.readInt(1,6);
                    switch(choice)
                    {
                        case 1:
                        {
                            cout << myBanking.ShowBalance() << endl;
                        break;
                        }
                        
                        case 2:
                        {
                            cout << "Please enter the amount in dollars you would like to deposit, followed by the amount in cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            myBanking.DepositAccount(dollars, cents);
                        break;
                        }
                        
                        case 3:
                        {
                            cout << "Please enter the amount in dollars you would like to withdraw, followed by the amount in cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            myBanking.WithdrawAccount(dollars, cents);
                        break;
                        }
                        
                        case 4:
                        {
                            for(int i = 0;i<10;i++)
                            {
                                if(myBanking.GetRecentTransactions(i) == "")
                                {
                                    cout << "none" << endl;
                                }else
                                {
                                cout << myBanking.GetRecentTransactions(i) << endl;
                                }
                            }
                            
                            cout << "Your last transaction was: " << myBanking.GetLastTransaction() << endl;
                        break;
                        }
                        
                        case 5:
                        {
                            myBanking.ClearRecentTransactions();
                        break;
                        }
                        
                        case 6:
                        {
                            done = true;
                        }
                    }
                }
            break;
            }
            
            //Checking account options
            case 2:
            {
                CheckingAccount myChecking;
                cout << "Set the dollar amount of your account balance" << endl;
                balance_dollars = reader.readInt(0);
                cout << "Set the cent amount of your account balance\n" << endl;
                balance_cents = reader.readInt(0,99);
                myChecking.SetDollars(balance_dollars);
                myChecking.SetCents(balance_cents);
                cout << "Please select from the following options." << endl;
                
                while(!done)
                {
                    cout << "1 - Show account balance\n2 - Deposit Money/Check\n3 - Withdraw/Write a check\n4 - Show recent transactions\n5 - Clear Transaction history\n6 - Exit ATM\n" << endl;
                    int choice = reader.readInt(1,6);
                    switch(choice)
                    {
                        case 1:
                        {
                            cout << myChecking.ShowBalance() << endl;
                        break;
                        }
                        
                        case 2:
                        {
                            cout << "Would you like to deposit money into your account or cash a check?" << endl;
                            cout << "Press 1 to deposit money and 2 to cash a check" << endl;
                            int choice = reader.readInt(1,2);
                            if(choice == 1)
                            {
                                cout << "Please enter the amount in dollars you would like to deposit, followed by the amount in cents\n" << endl;
                                dollars = reader.readInt(0);
                                cents = reader.readInt(0,99);
                                myChecking.DepositAccount(dollars, cents);
                            } else 
                            {
                                cout << "Please enter the dollar value of the check you are cashing, followed by the cent value" << endl;
                                dollars = reader.readInt(0);
                                cents = reader.readInt(0,99);
                                cout << "Please enter the amount you'd like to keep in dollars, followed by cents\n" << endl;
                                long kept_dollars = reader.readInt(0);
                                int kept_cents = reader.readInt(0,99);
                                myChecking.CashCheck(dollars, cents, kept_dollars, kept_cents);
                            }
                        break;
                        }
                        
                        case 3:
                        {
                            cout << "Please enter the check number that you are writing" << endl;
                            int check_number = reader.readInt(0);
                            cout << "Please enter the amount the check is for in dollars, followed by the amount in cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            myChecking.WriteCheck(check_number, dollars, cents);
                        break;
                        }
                        
                        case 4:
                        {
                            for(int i = 0;i<10;i++)
                            {
                                if(myChecking.GetRecentTransactions(i) == "")
                                {
                                    cout << "none" << endl;
                                }else
                                {
                                cout << myChecking.GetRecentTransactions(i) << endl;
                                }
                            }
                            
                        break;
                        }
                        
                        case 5:
                        {
                            myChecking.ClearRecentTransactions();
                        break;
                        }
                        case 6:
                        {
                            done = true;
                        }
                    }
                }
            break;
            }
            
            //Savings account options
            case 3:
            {
                SavingAccount mySavings;
                cout << "Set the dollar amount of your account balance" << endl;
                balance_dollars = reader.readInt(0);
                cout << "Set the cent amount of your account balance" << endl;
                balance_cents = reader.readInt(0,99);
                cout << "Select your interest rate\n" << endl;
                interest_rate = reader.readDouble();
                mySavings.SetDollars(balance_dollars);
                mySavings.SetCents(balance_cents);
                mySavings.SetInterestRate(interest_rate);
                cout << "Please select from the following options." << endl;
                while(!done)
                {
                    cout << "1 - Show account balance\n2 - Deposit\n3 - Withdraw\n4 - Show recent transactions\n5 - Clear Transaction history\n6 - Calculate Interest\n7 - Show interest accumulated\n8 - Exit ATM\n" << endl;
                    int choice = reader.readInt(1,8);
                    switch(choice)
                    {
                        case 1:
                        {
                            cout << mySavings.ShowBalance() << endl;
                        break;
                        }
                        
                        case 2:
                        {
                            cout << "Please enter the amount in dollars you would like to deposit, followed by the amount in cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            mySavings.DepositAccount(dollars, cents);
                        break;
                        }
                        
                        case 3:
                        {
                            cout << "Please enter the amount in dollars you would like to withdraw, followed by the amount in cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            mySavings.WithdrawAccount(dollars, cents);
                        break;
                        }
                        
                        case 4:
                        {
                            for(int i = 0;i<10;i++)
                            {
                                if(mySavings.GetRecentTransactions(i) == "")
                                {
                                    cout << "none" << endl;
                                }else
                                {
                                cout << mySavings.GetRecentTransactions(i) << endl;
                                }
                            }
                            
                        break;
                        }
                        
                        case 5:
                        {
                            mySavings.ClearRecentTransactions();
                        break;
                        }
                        
                        case 6:
                        {
                            mySavings.CalculateInterest();
                        break;
                        }
                        
                        case 7:
                        {
                            cout << "Interest accumulated this month: " << mySavings.GetInterestAccumulatedMonth() << endl;
                            cout << "Interest accumulated this year: " << mySavings.GetInterestAccumulatedYear() << "\n" << endl;
                        break;
                        }
                        
                        case 8:
                        {
                            done = true;
                        }
                    }
                }
            break;
            }
            
            //Credit Account options
            case 4:
            {
                CreditAccount myCredit;
                cout << "Set the dollar amount of your account balance" << endl;
                balance_dollars = reader.readInt(0);
                cout << "Set the cent amount of your account balance" << endl;
                balance_cents = reader.readInt(0,99);
                cout << "Select your interest rate. NOTE: Must be greater or equal to 0.0" << endl;
                interest_rate = reader.readDouble();
                cout << "Set the dollar amount for your max balance" << endl;
                long max_dollars = reader.readInt(0);
                cout << "Set the cent amount for your max balance\n" << endl;
                int max_cents = reader.readInt(0, 99);
                myCredit.SetDollars(balance_dollars);
                myCredit.SetCents(balance_cents);
                myCredit.SetMaxBalanceDollars(max_dollars);
                myCredit.SetMaxBalanceCents(max_cents);
                myCredit.SetInterestRate(interest_rate);
                
                cout << "Please select from the following options." << endl;
                while(!done)
                {
                    cout << "1 - Show account balance\n2 - Deposit\n3 - Withdraw\n4 - Calculate Interest\n5 - Clear Transaction history\n6 - Calculate interest\n7 - Show interest accumulated\n8 - Exit ATM\n" << endl;
                    int choice = reader.readInt(1,8);
                    switch(choice)
                    {
                        case 1:
                        {
                            cout << myCredit.ShowBalance() << endl;
                        break;
                        }
                        
                        case 2:
                        {
                            cout << "Please enter the amount you would like pay towards your balance in dollars, followed by cents\n" << endl << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            myCredit.MakePayment(dollars, cents);
                        break;
                        }
                        
                        case 3:
                        {
                            cout << "Please enter the transaction number for the charge" << endl;
                            int transaction = reader.readInt(0);
                            cout << "Please enter the amount of the transaction in dollars, followed by cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            myCredit.ChargeCard(transaction, dollars, cents);
                        break;
                        }
                        
                        case 4:
                        {
                            for(int i = 0;i<10;i++)
                            {
                                if(myCredit.GetRecentTransactions(i) == "")
                                {
                                    cout << "none" << endl;
                                }else
                                {
                                cout << myCredit.GetRecentTransactions(i) << endl;
                                }
                            }
                            
                        break;
                        }
                        
                        case 5:
                        {
                            myCredit.ClearRecentTransactions();
                        break;
                        }
                        
                        case 6:
                        {
                            myCredit.CalculateInterest();
                        break;
                        }
                        
                        case 7:
                        {
                            cout << "Interest accumulated this month: " << myCredit.GetInterestAccumulatedMonth() << endl;
                            cout << "Interest accumulated this year: " << myCredit.GetInterestAccumulatedYear() << "\n" << endl;
                        break;
                        }
                        
                        
                        case 8:
                        {
                            done = true;
                        }
                    }
                }
            }//break
        }
    }while(!end_program);
}
Exemple #19
0
//[IL_BankAccount_ATMWithdrawal
void ATMWithdrawal(BankAccount& acct, int sum) {
    acct.Withdraw(sum);
    /*<preemption possible>*/
    acct.Withdraw(2);
}
int main()
{
	int option;
	LinkedList PortfolioList;
	StockAccount stock;
	BankAccount myAccount;
	bool flag1=false;
	bool flag2=false;
	bool already_in_list=false;

	//for transaction file
	string trans_type [60], trans_sym[60], trans_time[60];
	double trans_price[60], trans_total[60];
	int trans_num[60];

	//for stocks file
	string company_name[60], date[60];
	double price_per_share[60];
	int account_index;
	int k=0, m=0;
	
	//for account information file
	string account_sym[60];
	double account_price[60], account_total[60];
	int account_num[60];

	//for Bank Account
	double myAmount;

	//transaction type
	string type;


	stock.readStockFile(company_name,price_per_share,date);										//read stock file
	stock.read_transaction_history(trans_type,trans_sym,trans_num, trans_price, trans_total,trans_time);	//read transaction history
	stock.read_account_information(account_sym,account_num, account_price, account_total);		//read account information

	double myBalance=PortfolioList.CopyToPortfolioList(PortfolioList,stock,account_sym,account_num, account_price, account_total);	//copy account information to Portfolio List
	
	cout<<"Welcome to the Account Management System.\n\n";

	while(1)
	{
		cout<<"Please select an account to access:"<<endl
			<<"1. Stock Portfolio Account"<<endl
			<<"2. Bank Account"<<endl
			<<"3. Exit"<<endl
			<<"Option: ";
		cin>>option;

		switch(option)
		{
		case 1:																		//Stock Management System
			cout<<"\n\nStock Portfolio Account"<<endl;
			while(1)
			{
				cout<<"Please select an option:"<<endl
					<<"1. Display the price for a stock symbol"<<endl
					<<"2. Display the current portfolio"<<endl
					<<"3. Buy shares"<<endl
					<<"4. Sell shares"<<endl
					<<"5. View transaction history"<<endl
					<<"6. Return to previous menu"<<endl;

				cin>>option;
				if(option==6)																	//return to previous menu
					break;
				switch(option)
				{
				case 1:			
					
					stock.display_stock_price(company_name,price_per_share);					//display stock price
					
					break;
				case 2:
					PortfolioList.~LinkedList();												//clear linked list
					stock.read_account_information(account_sym,account_num, account_price, account_total);	//read account information
					myBalance=PortfolioList.CopyToPortfolioList(PortfolioList,stock,account_sym,account_num, account_price, account_total);	//copy account information to LinkedList
					PortfolioList.SortLinkedList();												//sort the Linked List
					PortfolioList.printList();													//print the Linked List

					break;
				case 3:

					flag1=stock.buy_shares(company_name,price_per_share);						//buy shares
					already_in_list=stock.alreadyInList(account_sym,account_index);				//check to see if the stock is already in list

					if(flag1)																	//if transaction went through
					{
						type="Buy";
						if(already_in_list)														//if in list
						{
							stock.update_account_information(account_sym,account_num,account_price,account_total,account_index); //just update the list(no new entry)
						}
						else																	//if it's not in the list
						{
							stock.store_account_information(stock);								//store the stock in account information
						}
					}
					stock.store_transaction(stock,type);												//store tranaction in file
					break;	
				case 4:
					flag2=stock.sell_shares(account_sym,account_price);						//sell shares
					already_in_list=stock.alreadyInList(account_sym,account_index);			//check to see if the stock is already in list

					if(flag2)																//if transaction went through
					{
						type="Sell";
						stock.update_sell_information(account_sym,account_num,account_price,account_total,account_index); //just update the list
					}
					stock.store_transaction(stock,type);												//store tranaction in file
					break;

				case 5:
					stock.read_transaction_history(trans_type,trans_sym, trans_num, trans_price,trans_total, trans_time);
					cout<<"Event"<<setw(15)<<"Company Symbol"<<setw(9)<<"Number"<<setw(19)<<"Price per share"<<setw(15)<<"Total value"<<setw(11)<<"Time\n";
					while(trans_sym[m]!="END")
					{
						cout<<trans_type[m]<<setw(7)<<trans_sym[m]<<setw(15)<<trans_num[m]<<setw(15)<<trans_price[m]<<setw(19)<<trans_total[m]<<setw(18)<<trans_time[m]<<endl;
						m++;
					}
					m=0;
					cout<<"\n";
					break;
				default:
					cout<<"You entered an invalid number!"<<endl;
					break;
				}
			}
			break;
		case 2:
				//Bank Account
			cout<<"\n\nBank Account"<<endl;
			while(1)
			{
				cout<<"Please select an option:"<<endl
					<<"1. View account balance"<<endl
					<<"2. Deposit Money"<<endl
					<<"3. Withdraw Money"<<endl
					<<"4. Print out history"<<endl
					<<"5. Return to previous menu"<<endl;

				cin>>option;
				if(option==5)																	//return to previous menu
					break;
				switch(option)
				{
				case 1:
					myAccount.View_balance();													//View Balance
					break;
				case 2:
					cout<<"Please enter the amount: "<<endl;
					cin>>myAmount;
					myAccount.Deposit(myAmount);
					break;
				case 3:
					cout<<"Please enter the amount: "<<endl;
					cin>>myAmount;
					myAccount.Withdraw(myAmount);
					break;
				case 4:
					myAccount.Print_history();
					break;
				default:
					cout<<"You entered an invalid number!"<<endl;
					break;
				}
			}
			break;
		case 3:												//exit the program
			exit(0);
		default:
			break;
		}
	}

	return 0;
}
Exemple #21
0
int main()
{
	vector<BankAccount*> accounts;
	do
	{
		int index = 0;
		int userAccount = 0;
		int choice = menu();
		if (choice == 1) //Open
		{
			int type = accountType();//determines account type
			cout << "What name did your mom and pop give you?\n"; //Gathering account info. It makes more sense to me to do this in main with a constructor as opposed to a member function.
			string name = "";
			cin >> name; //I assume they user will only enter either a first name.
			bool validCheck = false;
			string initialDeposit;
			do //checks if valid choice y or n
			{

				cout << "Would you like to start with an initial deposit? (y/n)\n";
				initialDeposit = "";
				cin >> initialDeposit;
				if (initialDeposit == "y" || initialDeposit == "n")
				{
					validCheck = true;
				}
				else
				{
					cout << "That isn't one of the choices. Come on now.\n\n";
				}
			}
			while (validCheck == false);
			double initialDepositAmount = 0;
			if (initialDeposit == "y")
			{

				bool posCheck = false;
				do//Ensures only positive desposits.
				{

					cout << "How much you wanna deposit?\n";
					cin >> initialDepositAmount;

					if (initialDepositAmount < 0)
					{
						cout << "You may only deposit postive money...\n";
					}
					else
					{
						posCheck = true;
					}
				}
				while (!posCheck);
			}

			if (type == 1) //Checking
			{
				BankAccount* temp = new CheckingAccount(accountCounter, initialDepositAmount, name);
				cout << temp->tostr();
				accountCounter++;
				accounts.push_back(temp);
			}
			else if (type == 2)//Savings
			{
				BankAccount* temp = new SavingsAccount(accountCounter, initialDepositAmount, name);
				cout << temp->tostr();
				accountCounter++;
				accounts.push_back(temp);
				//Savings.open()
			}
			else if (type == 3)//CD
			{
				BankAccount* temp = new CDAccount(accountCounter, initialDepositAmount, name);
				cout << temp->tostr();
				accountCounter++;
				accounts.push_back(temp);
				//CD.open()
			}
		}