Banking System Project dillemma
Feb 19, 2015 at 10:08am UTC
Hello all, I am a newbie here and this is my first post to this forum so do bear with me. I need help in configuring my program, here's the thing, I already managed to make this block of code [located below] and I need help in making the cash amount registered to evaluate continuosly, like from 0-1000 from first deposit then from 1000 I'd probably withdraw 800, making it 200, but my problem is it keeps on going back to 0, I really don't know what to do. Suggestions are very much welcome. THANKS.
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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
#include <iostream>
#include <cstdlib>
using namespace std;
//variables
int dAMNT, wAMNT;
char name[50];
int amount1=0, contact;
int accno=112356;
int balance=0;
char address[50];
int ques;
int loop1;
//view credentials
void View (){
cout<<"\n \nNAME: \t \t " <<name;
cout<<"\n \nADDRESS: \t " <<address;
cout<<"\n \nCONTACT #: \t " <<contact;
cout<<"\n \nACCOUNT #: \t " <<accno;
cout<<"\n \nBALANCE: \t " <<balance;
}
//deposit func
void Deposit () {
int dAMNT;
cout<<"\n \n \n BALANCE: P " <<balance;
cout<<"\n Amount to deposit:" ;
cin>>dAMNT;
cout<<"\n Balance:" <<dAMNT+balance;
}
//withdraw func
void Withdraw (){
int wAMNT;
cout<<"\n \n \n BALANCE: P " <<balance;
cout<<"\n Amount to withdraw:" ;
cin>>wAMNT;
cout<<"\n Balance:" <<balance-wAMNT;
}
//create account func
void CreateAcc (){
cout<<"\n \n \t Welcome to the our Banking System!!" <<endl;
cout<<"\n \n \t \t Please create an account... \n " <<endl;
cout<<"\t NOTE: YOU WILL BE ASSIGNED AN ACCOUNT \n\tNUMBER AFTER YOU REGISTER..." ;
cout<<"\n \n Enter your name:" ;
cin>>name;
cout<<"\n \n Input your address:" ;
cin>>address;
cout<<" \n \n Input your contact #:" ;
cin>>contact;
cout<<"\n Account Number:" <<accno<<endl;
system ("cls" );
system ("color 3E" );
cout<<"\n \n \t You have successfully created your account!!!\n \n " ;
cout<<"\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" ;
cout<<"\n \n \t \t \t YOUR CREDENTIALS \n " ;
cout<<"\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n " ;
cout<<"\n \nNAME: \t \t " <<name;
cout<<"\n \nADDRESS: \t " <<address;
cout<<"\n \nCONTACT #: \t " <<contact;
cout<<"\n \nACCOUNT #: \t " <<accno;
cout<<"\n \nBALANCE: \t " <<balance;
}
int main () {
char switcheroo;
do {
cout<<"\n \n Please choose your action: \n " ;
cout<<" \n 01. Create Account" ;
cout<<" \n 02. Deposit Amount" ;
cout<<" \n 03. Withdraw Amount" ;
cout<<" \n 04. View Credentials" ;
cout<<" \n 05. EXIT" ;
cout<<" \n \n \n Enter choice:" ;
cin>>switcheroo;
system ("cls" );
switch (switcheroo){
case '1' :
CreateAcc();
break ;
case '2' :
Deposit();
break ;
case '3' :
Withdraw();
break ;
case '4' :
View();
break ;
case '5' :
system ("color D" );
default : cout<<"\a " ;
};
}while (switcheroo!='5' );
return 0;
system ("pause" );
}
Feb 19, 2015 at 2:53pm UTC
but my problem is it keeps on going back to 0
It doesn't go back to 0, you just never change
balance
.
After line 60 there should be:
1 2 3
cin>>wAMNT;
balance-=wAMNT; // Note: this changes balance
cout<<"\n Balance:" << balance;
Deposit ()
has the same problem.
Feb 21, 2015 at 6:58am UTC
hey thanks a lot. ^_^
Topic archived. No new replies allowed.