Sie sind auf Seite 1von 4

#ifndef ACCOUNT_H

#define ACCOUNT_H
#include <string>
#include <iostream>

using namespace std;

class Account {
public:
Account(){
accountNumber = 0;
balance = 0;
};
Account(int account, double bal);
void withdraw(double amount);
void deposit(double amount);
double balanceRequest();
void print();
double fee(bool fee);
bool accountN(int stuff);

private:
int accountNumber;
double balance;

};

#endif ACCOUNT_H

#include "account.h"

Account::Account(int account, double bal){


accountNumber = account;
balance = bal;
}

void Account::withdraw(double amount){

if (balance < amount){


cout << "You have insuficent funds. a Fee has been applied.\n\n";
balance -= 10;
}
else if (balance >= amount)
{
balance -= amount;

void Account::deposit(double amount){


balance += amount;

void Account::print(){
cout << "Your account number is " << accountNumber << ".\n";
cout << "Your balance is " << balance << ".\n";
}

double Account::balanceRequest(){
return balance;
}

bool Account::accountN(int stuff){

if (stuff == accountNumber)
return true;
else
return false;

#include "Account.h"
#include <string>
#include <iostream>

using namespace std;

void transfer(Account& to, Account& from, double amount){

if (from.balanceRequest() > amount){


to.withdraw(amount);
from.deposit(amount);
}
else cout << "insufficient fund";
}

/*
int main(){

Account account1(1667589, 10000);


Account account2(1569856, 9586);
Account account3(2986957, 1);
account1.withdraw(20);
account2.withdraw(10000);
account1.deposit(100);
account2.deposit(0);

account1.print();
account2.print();

return 0;
}
*/
int main(){
Account();
Account account1(1114, 10000);
Account account2(1116, 9586);
Account account3(1115, 1000);
int input, accountNum, accountNum2;
bool more = false;
double amount;
cout << "Please enter your account number.\n";
cin >> accountNum;
Account n, b;

if (account1.accountN(accountNum)){
n = account1;
more = true;
}
else if (account2.accountN(accountNum)){
n = account2;
more = true;
}
else if (account3.accountN(accountNum)){
n = account3;
more = true;
}
if (account1.accountN(accountNum) || account2.accountN(accountNum) ||
account3.accountN(accountNum)){
while (more){
cout << "Please enter a selection from the items below.\n1.
Balance\n2. Withdraw \n3. Deposit \n4. Exit\n\n";
cin >> input; cout << endl;
switch (input)
{
case 1: cout << "Your balance is $" << n.balanceRequest() <<
".\n\n"; break;
case 2: cout << "Enter amount to withdraw.\n\n"; cin >> (amount);
n.withdraw(amount); break;
case 3: cout << "Enter amount to deposit\n\n"; cin >> amount;
n.deposit(amount); break;
case 4: more = false; break;
default: "Please enter a valid selection.\n"; break;
}
}
}
else
cout << "Not a valid account\n";

cout << "Please enter your account number.\n";


cin >> accountNum;
cin >> accountNum2;

if (account1.accountN(accountNum)){
n = account1;
}
else if (account2.accountN(accountNum)){
n = account2;
}
else if (account3.accountN(accountNum)){
n = account3;
}
if (account1.accountN(accountNum) || account2.accountN(accountNum) ||
account3.accountN(accountNum)){
transfer(n, account2, 100);

}
cout << n.balanceRequest();
cout << account2.balanceRequest();
return 0;
}

Das könnte Ihnen auch gefallen