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
|
#include <iomanip>
#include <iostream>
#include <conio.h>
#include <math.h>
#include <fstream>
using namespace std;
//In the main have the create and log in.
//Ask the user if they want to create an account, if yes then have them create an account then restart the program.
//Have the user log in, if the pin is invalid close the program. Have switch statement for the other options of...
//Each of the following are void ___ ()
//Check your balance: Displays your current balance.
//Make a withdraw: Enter in the amount to be taken out, subtract that from the total, use an if to see if the person has sufficient funds with subtraction
//Make a deposit: Enter in the amount to enter, add it to the total, display new amount.
//This program is pretty broken right now expect a ton of errors to fix later.
void deposit ()
{
ifstream infile;
string apin;
int pin,found,searchpin,choice2;
char choice;
double wealth, deposit;
cout<<"Enter in your account 4-digit pin: "; //Must have to enter in a file to open.
getline (cin,apin);
infile.open(apin+".txt");
infile.open(apin.c_str());
cout<<endl<<"How much money do you wish to deposit?";
cin>>deposit;
wealth = deposit + wealth;
cout<<endl<<"Your account now has: $"<<wealth;
}
void withdraw ()
{
ifstream infile;
string apin;
int pin,found,searchpin,choice2;
char choice;
double wealth, withdraw;
cout<<"Enter in your account 4-digit pin: "; //Must have to enter in a file to open.
getline (cin,apin);
infile.open(apin+".txt");
infile.open(apin.c_str());
cout<<endl<<"How much money do you wish to withdraw?";
cin>>withdraw;
wealth = wealth - withdraw;
cout<<endl<<"Your account now has: $"<<wealth;
}
void checkbalance ()
{
ifstream infile;
string apin;
int pin,found,searchpin,choice2;
char choice;
double wealth;
cout<<"Enter in your account 4-digit pin: "; //Must have to enter in a file to open.
getline (cin,apin);
infile.open(apin+".txt");
infile.open(apin.c_str());
cout<<endl<<"Your account currently has: $"<<wealth;
}
int main ()
{
ifstream infile;
string apin;
int pin,found,searchpin,choice2;
char choice;
double wealth;
cout<<"Do you have an account with us? (Y) or (N).";
cin>>choice;
if (choice == 'N')
{
cout<<"Please enter in the following information for creating the account: "<<endl;
cout<<"Enter in your account 4-digit pin: "; //Must have to enter in a file to open.
getline (cin,apin);
apin=apin+".txt";
infile.open(apin.c_str());
cout<<endl<<"Enter in your 4-digit pin number: ";
infile>>pin;
cout<<"Please enter in how much money you are going to be depositing from the start: ";
cin>>wealth;
cout<<endl<<"Your account has been created. Please log off and back on.";
}
else if (choice == 'Y') //This is for logging in, use a nested if for if the password is right and all...then use the nested if so you can access the other options of dipositing, withdrawing, etc.
{
found = 0;
cout<<"Enter in your account PIN: ";
getline (cin,apin);
infile.open(apin+".txt");
cout<<"Enter in your PIN number: ";
cin>>searchpin;
infile>>pin;
if (searchpin == pin)
{
cout<<"Welcome! Please choose which option you wish to prusuit"<<endl;
cout<<"Make a deposit (1)"<<endl;
cout<<"Withdraw money (2)"<<endl;
cout<<"Check your balance (3)"<<endl;
cin>>choice2;
switch (choice2)
{
case 1: deposit();
break;
case 2: withdraw();
break;
case 3: checkbalance();
break;
}
}
}
return 0;
}
|