code right or
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
![Savang saV nterest(annuallnterestRate);
(to antsetBalance(intialalance):
1Sop
Run Detug
MSae
men op
9include dostrean
include cfstrean
3 includecstring
4 using nanespace std;
class Account(
int id;
double balance;
publies
r
20
Account ()(
id-
balance =e.e;
21
12
14
Account (int newID, double initialBalance){
id- newlD;
balance-initial8alance;
15
16
17
18
29
20
21
veid setI0(int newID){
id newID;
void settalance(double initialBalance){
balance initialalance,
23
24
25
int getID()
return id;
26
27
28
29
double getsalance(){
return balance;
30
31
void withdraw(double amount){
balance - balance- ount;
32
33
34
35
void deposit(double anount){
balance balance mount,
36
37
38
virtual void closetonth()-e
39
virtual string accountstring()-
41
42
43 );
44 elass Savings:publie Account{
double interest;
double minbalance;
public:
Savings()
46
47
48
49
se
void eloselonth(){
double pre- getsalance();
52
53
double newdalance- pre ((pre (interest/100.0))/12.0):
54
55
setBalance(newBalance);
56
string accountstring()
57
+ to_string(getID()) has balance of S"ito_string(getsalance());
59
return "SavingE account
61
void setInterest(double interest){
this-interest-interest;
62
63
64
void setMintalance(double minlalance)(
this-mintalance minsalance;
65
66
69- class Checking public Account(
double mintalance;
double monthlyree;
71
72 public:
73
Checking(){
74
75
void closelonth()
double nelalance getsalance()
setalance(newalance);
76
77
78
79
monthlyfee,
string accountstring()
81-
return "Checking account + to string(getID()) +" has balance of $"-to_string(gettalance());
82
83
84
85
void setMonthlyFee(double monthlyFee){
this-nonthlyfee nonthlyfee;
86
87
void setMinlalance(double minialance){
this-minalance = minsalance;
88
89
91
92 );
93
94 int nainO{
95
Accountaccounts = new Account [10];
ifstrean infile;
infile.open("bank2.txt");
1n länfile )
cerr « "File cannont be opened" <« endl;
else
cout e "File Opened"endl;
string operationType;
int tetalaccount
96
97
98
99
100
101
102
103
while(infileoperationType)
104
105
106
107
if(operationType "Savings"H
int id;
double initialBalance,minimunbalance, annualInterestRate;
infile > id» initialBalance
Savings "savingAccount
savingiccount-setInterest(annualinterestRate);
savingaccount-setMinbalance(ninimunalance);
accounts (totalAccount) savingaccount:
accounts[totalAccount]-setID(id);
accounts(totalAccount]-setBalance(initialBalance);
tetalAccount-
cout "Saving account nunber "cctotalAccount « created"<endl;
cout"with an initial balance of saccounts[totalAccount-1]-getBalance()cendi;
108
»
new Savings();
minimunsalance » annualInterestRate;
109
11e
111
112
113
114
115
116
117
118
119
12e
121
122
123
124
125
else if(operationType == "Checking"{
int id;
double initialBalance,minimunbalance, monthlyfees;
infile > id» initial8alance inimunalance >> monthlyfees:
Checking "checkingaccount- new Checking():
checkingAccount-setMonthlyFee(monthlyFees);
checkingiccount-setkinBalance(mininunBalance);
accounts[totalAccount]- checkingAccount;
accounts(totalAccount)-setiD(id);
accounts[totalAccount]setBalance(initialBalance);
tetalAccount
cout "Checking account nunber "cctotalAccount «* created"<cendl;
cout"with an initial balance of S"accounts(totalAccount-1]-gettalance()cendl;
126
127
128
129
130
131
132
133](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F47577806-debe-455c-b0cc-e7afa6e96ab3%2Ffd2207ba-c502-4935-ac41-64e25f698b6c%2F34zubfl_processed.jpeg&w=3840&q=75)
![coutewith an initial balance of S"caccounts[totalAccount-1]-getBalance()<cendl;
133
134
135
else if (operationType "Deposit"){
int id;
double amount;
int pos;
bool isFound-=false;
infile >> id > anount;
for(int i-e;i totalAccount;i++){
if (accounts[i]-getID()--id){
136
137
138
139
148
141
142
143
isFound-true;
accounts [i]->deposit(amount);
pos-i;
144
145
146
147
148
if(lisFound){
cout"Invalid Account Number - "<cidccendl;
149
150
151
152
153
elsef
cout cc"Deposited $"<camountce" into account "<cidccendl;
cout<<"current balance is $"<caccounts[pos]-getBalance()<<endl;
154
155
156
else if (operationType == "kithdraw"){
int id;
double amount;
int pos;
infile >> id >> anount;
bool isFound-false;
for(int i-e;itotalAccount;i+){
if (accounts[i]-getID()--id){
157
158
159
160
161
162
163
164
165
isFound-true;
accounts (i]-withdraw(amount);
pos i;
166
167
168
169
178
171
ir(lisFound){
coutce"Invalid Account Number - "ccidccendl;
172
173
elsef
cout ccwithdraw $"ccamount c" from account recidccendl;
coute"current balance is S"caccounts[pos]-getBalance()< cendl;
174
176
177
else if (operationType "Balance"){
int id;
infile >» id;
int pos;
178
179
180
181
bool isFound-false;
for (int i-e;ictotalAccount;i){
if (accounts[i]->getID()=-id){
isFound true;
182
184
185
cout"Current balance in account "ccid e" is S"caccounts[i] getBalance()<cendl;
186
pos i;
187
188
189
ir(lisFound){
coutce"Invalid Account Number
190
191
*c«idccendl;
192
193
194
else if (operationType = "Close"){
cout"End of nonth processing complete"ccendl;
for(int i-e;itotalAccount;i+){
accounts[i]->closeMonth();
195
196
197
198
199
else if (operationType "Report"){
for (int i-e;itotalAccount;i+){
cout « accounts[i]->accountString() « endl;
200
201
202
203
204
elsef
coute"Unrecognised command
string dunnyline;
getline(infile, dumnyline);
205
"ccoperationTypeccendl;
208
afile.close();
213
Input
Wan t](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F47577806-debe-455c-b0cc-e7afa6e96ab3%2Ffd2207ba-c502-4935-ac41-64e25f698b6c%2Fvqgn6t_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)