You are on page 1of 5

004 #include <stdlib.

h>
005 #include <iostream.h> // standard input output functions
006 #include <iomanip.h> // format output
007 #include <fstream.h> // must be included to access files
008 #include <math.h> // Built-in Math functions
009 #include "utilities.h"
010 #include "apstring.h"
011 #include "apvector.h"
012 using namespace std;
013
014 ////////////////////////////////////////////////////////////////////////
015 // FUNCTION PROTOTYPES //
016 ///////////////////////////////////////////////////////////////////////
017
018 double GetCustomer(void);
019 //pin, name, intial balance
020 double GetBalance(double balance);
021 //displays the balance
022 double MakeWith(double balance);
023 //can make a withdrawel
024 void Card(void);
025 //displays card
026 void Title(void);
027 //screen shown at the beginning of the game
028 double MakeDeposit(double balance);
029 //makes deposit
030 int Menu (void);
031 //menu
032
033 ////////////////////////////////////////////////////////////////////////
034 // MAIN FUNCTION //
035 ///////////////////////////////////////////////////////////////////////
036
037
038
039 int main()
040 {
041 int choice;
042 int balance;
043
044 do{
045
046 Title();
047
048 balance = GetCustomer();
049
050 do{
051 Menu();
052 choice = Menu();
053
054 if(choice == 1)
055 balance = GetBalance(balance);
056
057 if(choice == 2)
058 balance = MakeDeposit(balance);
059
060 if(choice == 3)
061 balance = MakeWith(balance);
062
063 if(choice == 4)
064 Card();
065 }
066 while (choice !=5);
067
068
069 } while (!Exit("[A] Another Program, [E] Exit",'A','E'));
070 return (EXIT_SUCCESS);
071 }//End Main
072
073 ////////////////////////////////////////////////////////////////////////
074 // FUNCTION DEFINITIONS //
075 ///////////////////////////////////////////////////////////////////////
076
077 double GetCustomer(void)
078 {
079 string first_name, middle, last_name;
080 int pin,balance;
081
082 //pin display
083 cout<<"Please enter your pin number: "<<endl;
084 cout<<" ___ ___ ___ "<<endl;
085 cout<<" | | | | | |"<<endl;
086 cout<<" | 1 | | 2 | | 3 |"<<endl;
087 cout<<" |___| |___| |___|"<<endl;
088 cout<<" ___ ___ ___ "<<endl;
089 cout<<" | | | | | |"<<endl;
090 cout<<" | 4 | | 5 | | 6 |"<<endl;
091 cout<<" |___| |___| |___|"<<endl;
092 cout<<" ___ ___ ___ "<<endl;
093 cout<<" | | | | | |"<<endl;
094 cout<<" | 7 | | 8 | | 9 |"<<endl;
095 cout<<" |___| |___| |___|"<<endl<<endl;
096 cin>>pin;
097
098 //name
099 cout<<"Please enter your full name (Middle Initial) "<<endl;
100 cout<<"Name ";
101 cin>>first_name>>middle>>last_name;
102 cout<<endl;
103 cout<<"Thank you "<<first_name<<" "<<middle<<". "<<last_name<<" for
using ";
104 cout<<"our ATM"<<endl<<endl;
105 //displays first balance
106 balance = Random(100,1000);
107
108 cout<<"Your current balance is $"<<balance<<endl<<endl;
109 return balance;
110
111 }
112
113
114 double GetBalance(double balance)
115 {
116 cout<<"Your current balance is: "<<balance<<endl;
117 return balance;
118 }
119 int Menu (void)
120 {
121 int choice;
122 choice = Menu ();
123
124 cout<<"Please select a banking activity: ";
125
126 cout<<"@@@@@@@@@@@@@@@@@@@@@@"<<endl;
127 cout<<"@ 1. Current balance @"<<endl;
128 cout<<"@@@@@@@@@@@@@@@@@@@@@@"<<endl;
129 cout<<endl;
130
131 cout<<"@@@@@@@@@@@@@@@@@@@@@"<<endl;
132 cout<<"@ 2. Deposit @"<<endl;
133 cout<<"@@@@@@@@@@@@@@@@@@@@@"<<endl;
134 cout<<endl;
135
136 cout<<"@@@@@@@@@@@@@@@@@@@@@"<<endl;
137 cout<<"@ 3. Withdrawl @"<<endl;
138 cout<<"@@@@@@@@@@@@@@@@@@@@@"<<endl;
139 cout<<endl;
140
141 cout<<"@@@@@@@@@@@@@@@@@@@@@"<<endl;
142 cout<<"@ 4. Eject Card @"<<endl;
143 cout<<"@@@@@@@@@@@@@@@@@@@@@"<<endl;
144 cout<<endl;
145
146 cin>>choice;
147
148 return choice;
149 }
150 double MakeWith(double balance)
151 {
152 int with_amount;
153
154 cout<<"How much money would you like to withdraw from your account?
"<<endl;
155 cout<<"(Less than $300)"<<endl;
156 cout<<"$";
157 cin>>with_amount;
158 cout<<endl;
159
160 if(with_amount%20==0&&with_amount<=300&&with_amount<=balance)
161 {
162 balance = balance-with_amount;
163 return balance;
164 }
165
166
167 if(with_amount%20!=0)
168 {
169 cout<<"Error: Amount not a mulitple of $20"<<endl;
170 Pause();
171 Pause();
172 }
173
174 if(with_amount>300)
175 {
176 cout<<"Error: Amount too large"<<endl;
177 Pause();
178 Pause();
179 }
180
181 if(with_amount>balance)
182 {
183 cout<<"Error: There is going to be a negitive balance"<<endl;
184 Pause();
185 Pause();
186 }
187
188 }
189
190 void Title (void)
191 //screen shown at the beginning of the game
192 {
193 cout<<endl<<endl<<endl;
194 cout<<setw(60)<<"@ @ @ @@@@ @ @@@@ @@@@ @@ @@ @@@@"<<endl;
195 cout<<setw(60)<<" @ @ @ @ @@ @ @ @ @ @ @ @ @@ "<<endl;
196 cout<<setw(60)<<" @ @ @@@@ @@@@ @@@@ @@@@ @ @ @@@@"<<endl;
197 cout<<setw(60)<<" "<<endl;
198 cout<<setw(60)<<" @@@@@ @@@@ "<<endl;
199 cout<<setw(60)<<" @ @ @ "<<endl;
200 cout<<setw(60)<<" @ @@@@ "<<endl;
201 cout<<setw(60)<<" "<<endl;
202 cout<<setw(60)<<" @@@@@ @ @ @@@@ "<<endl;
203 cout<<setw(60)<<" @ @@@@ @@ "<<endl;
204 cout<<setw(60)<<" @ @ @ @@@@ "<<endl;
205 cout<<setw(60)<<" "<<endl;
206 cout<<setw(60)<<" @ @@@@@ @@ @@ "<<endl;
207 cout<<setw(60)<<" @@@ @ @ @ @ "<<endl;
208 cout<<setw(60)<<" @ @ @ @ @ "<<endl;
209
210 Pause();
211 system("clear");
212 }
213
214 double MakeDeposit(double balance)
215 {
216 double deposit;
217 cout<<"Enter the amount you would like to deposit. The";
218 cout<<"amount must be not exceed three hundred dollars."<<endl;
219 cin>>deposit;
220
221 if(deposit>300)
222 cout<<"Error"<<endl;
223
224 if(deposit<=300)
225 balance = balance + deposit;
226 }
227
228
229
230 void Card(void)
231 {
232 system("clear");
233
234 cout<<" ________________________________________ "<<endl;
235 cout<<"| The First C++ Bank|"<<endl;
236 cout<<"| ^_^_^^ |"<<endl;
237 cout<<"| @##$##$ /| * |"<<endl;
238 cout<<"| %%&! / |= * |"<<endl;
239 cout<<"| /__| =* |"<<endl;
240 cout<<"| 4756 4584 4839 5997 |"<<endl;
241 cout<<"| 4756 |"<<endl;
242 cout<<"| MM/YY |"<<endl;
243 cout<<"| 4/10 |"<<endl;
244 cout<<"| Official C++ Card Holder |"<<endl;
245 cout<<"|________________________________________|"<<endl;
246
247 cout<<"Thank you for using our ATM. Have a nice day!"<<endl;
248 }

You might also like