-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.h
126 lines (113 loc) · 3.8 KB
/
account.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include<iostream>
#include<iomanip>
using namespace std;
#ifndef account_H
#define account_H
#include "customer.h"
#include "transaction.h"
#include<string.h>
class acnt
{
public:
string acntno;
double balance;
double tdeposit;
double twithdrawal;
int tcount;
custom holder;
transaction tlist[100];
void printreport(acnt* acntobj);
void recorddeposit(acnt* acntobj,transaction *transc);
void recordwithdraw(acnt* acntobj,transaction *transc);
acnt()
{
acntno="06-3121-1021-0001";
balance=0;
tdeposit=0;
twithdrawal=0;
}
acnt (const custom &aholder, const string &aacntno, const string &transdate, const double &abalance=0)
{
holder=aholder;
acntno=aacntno;
balance=abalance;
tdeposit=abalance;
twithdrawal=0;
tlist[0].transdate = transdate;
tlist[0].transdesc = "opening balance";
tlist[0].deposit=abalance;
tlist[0].trbalance=abalance;
tlist[0].withdraw=0;
tlist[0]=transaction(transdate,"OPENING BALANCE",abalance);
tcount=1;
}
};
acnt acc;
acnt account[2];
void acnt :: printreport(acnt* acntobj)
{
cout<<"ACCOUNT SUMMARY "<<acntobj->acntno<<"-"<<acntobj->holder.custname<<endl<<endl;;
cout<<right<<setw(20)<<"Total Deposits:"<<right<<setw(9)<<" $"<<acntobj->tdeposit<<" DR"<<endl;
cout<<right<<setw(23)<<"Total Withdrawals:"<<right<<setw(5)<<" $"<<acntobj->twithdrawal<<" CR"<<endl;
cout<<right<<setw(19)<<"Final Deposit:"<<right<<setw(10)<<" $"<<acntobj->balance<<" DR"<<endl;
cout<<endl;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << left << setw(15) <<"Date"<< setw(20) << "Description"<< setw(15) <<"Deposit"<< setw(15) <<"Withdrawal"<<" Balance\n";
for(int i = 0; i < 80; i++)
cout << "=";
cout << "\n";
for(int i=0;i<acntobj->tcount; i++)
{
cout <<left<<setw(15)<<acntobj->tlist[i].transdate;
cout << left << setw(20) <<acntobj->tlist[i].transdesc;
if(acntobj->tlist[i].deposit!=0)
cout << left << setw(15) <<acntobj->tlist[i].deposit;
else
cout << left << setw(15) <<" ";
if((acntobj->tlist[i].withdraw)!=0)
cout << left<< setw(15) <<(acntobj->tlist[i].withdraw);
else
cout << left << setw(15) <<" ";
/*if(i==0)
{
cout << left << setw(15) <<acntobj->tlist[i].trbalance<<endl;
}
else
{*/
acntobj->tlist[i].trbalance=(acntobj->tlist[i-1].trbalance)-(acntobj->tlist[i].withdraw)+(acntobj->tlist[i].deposit);
//BUG CAUSING -VE 0.00 Below line
cout << left <<setw(15) <<acntobj->tlist[i].trbalance<<endl;
}
}
void acnt :: recorddeposit(acnt *acntobj,transaction *transc)
{
if((transc->transamt) >0)
{
acntobj->balance=acntobj->balance+transc->transamt;
acntobj->tdeposit=acntobj->tdeposit+transc->transamt;
transc->trbalance=transc->trbalance+transc->transamt;
acntobj->tlist[acntobj->tcount]=*transc;
acntobj->tcount+=1;
}
else
cout<<"Amount entered should be greater than zero\n";
}
void acnt :: recordwithdraw(acnt * acntobj,transaction * transc)
{
if(acntobj->balance>=transc->transamt)
{
acntobj->balance=acntobj->balance-transc->transamt;
acntobj->twithdrawal=acntobj->twithdrawal+transc->transamt;
transc->trbalance=transc->trbalance-transc->transamt;
acntobj->tlist[acntobj->tcount]=*transc;
acntobj->tcount+=1;
}
else
{
cout<<"Sorry! There is no money in your account."<<endl;
}
acntobj->tcount++;
}
#endif