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
|
#include <iostream>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
#include <windows.h>
#include <unistd.h>
using namespace std;
int addition (int d, int e)
{
int f;
f = d + e;
return f;
}
int subtraction (int g, int h)
{
int j;
j = g - h;
return j;
}
int main(void)
{
int a;
float b = 10000;
int c;
HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
DWORD mode = 0;
GetConsoleMode(hStdin, &mode);
SetConsoleMode(hStdin, mode & (~ENABLE_ECHO_INPUT));
string s;
std::string pincode;
retry:
cout<< "***********************************************************\n";
cout<< "*************Welcome to our simple ATM Machine*************\n";
cout<< "***********************************************************\n";
cout<< "\nEnter your pincode please: ";
getline(cin, pincode);
int pinlength = pincode.size();
std::string pin;
for (int i = 0; i < pinlength; i++)
{
pin += "*";
}
cout << pin << endl;
cout<< "\nSuccess!\nAccessing your data..........................";
sleep(3);
system ("CLS");
repeat:
cout<< "\n\nPlease select one of three options:\n";
cout<< "[1] Balance Inquiry\n[2] Withdraw\n[3] Deposit\n\n";
cout<< "Option selected: ";
cin>> a;
system ("CLS");
if (a==1)
{
cout<< "\nYour current balance is: " << b;
}
else if (a==2)
{
cout<< "\nPlease enter how much you would like to withdraw: ";
cin>> c;
system ("CLS");
if (c>b)
{
cout<< "\nError, insufficient balance.";
}
else if (c<=0)
{
cout<< "\nError, the amount cannot be less than 1.";
}
else
{
b = subtraction (b, c);
cout<< "\nTransaction successful, your current remaining balance is: " << b;
}
}
else if (a==3)
{
cout<< "\nPlease enter how much you would like to deposit: ";
cin>> c;
system ("CLS");
if (c<=0)
{
cout<< "\nError, the amount cannot be less than 1.";
}
else
{
b = addition (b, c);
cout<< "\nTansaction successful, your current balance is now: " << b;
}
}
else
{
cout<< "\n\nInvalid choice.";
goto repeat;
return 0;
}
cout<< "\n\nWould you like to do something else?\n";
cout<< "Select an option:\n\n";
cout<< "[1] Yes\n[2] No\n\n" << "Option selected: ";
cin>>c;
system ("CLS");
if (c==1)
{
goto repeat;
}
else if (c==2)
{
cout<< "\n\nThank you for using group 2's simple ATM Machine!";
return 0;
}
else
{
cout<< "\n\nInvalid option chosen.";
return 0;
}
}
|