Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Account
- {
- int id;
- float balance;
- float history[100];
- int transactions;
- public:
- Account(int newId,float newBalance)
- {
- id=newId;
- balance=newBalance;
- transactions=0;
- }
- float getBalance()
- {
- return balance;
- }
- int getId()
- {
- return id;
- }
- void transaction(float value)
- {
- history[transactions]=value;
- balance+=value;
- transactions++;
- }
- float last()
- {
- return history[transactions-1];
- }
- void showHistory()
- {
- float temp=balance;
- for(int i=transactions;i>0;i--)
- {
- temp=temp-history[i-1];
- cout<<"Transaction number:"<<i<<" Value transacion:"<<history[i-1]<< " Balance:"<<temp<<endl;
- }
- }
- };
- int main()
- {
- Account account(100,1000);
- account.transaction(1);
- account.transaction(2);
- account.transaction(3);
- account.transaction(4);
- account.transaction(5);
- account.transaction(6);
- account.showHistory();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement