Hello guys!!i am so desperate now .i cant seem to get the past value for the balance when i prompt the user to make a new transaction.the deposit balance wont saved .:( .and i want to use ofstream for Pin account and password.any help? this is my code so far.i need answers asap please:(.this project due 2days from now...
void userinput();
void displaybalance(int x);
int depositbalance(int a, int b);
int withdrawSum(int x, int y);
void accountinput();
int balanceholder(float x);
while (choice != 4)
{
switch (choice)
{
case 1:
displaybalance(balance);
system("pause");
break;
case 2:
cout << "Your Current Balance is " << balance << endl;
cout << "How much Money you want to deposit:" << endl;
cin >> deposit;
balance = depositbalance(balance, deposit);
cout << "Your newbalance is :" << endl;
cout << balance;
cout << endl;
cout << " PRESS 4 TO MAKE A NEW TRANSACTION AND PRESS 5 TO EXIT?" << endl;
cin >> answer;
if (answer == 4 || answer == 4)
return userinput();
else if (answer == 5 || answer == 5)
return;
else
cout << "Please Enter a Valid choice" << endl;
break;
case 3:
cout << "Your Current Balance is " << balance << endl;
cout << "How much Money do you want to withdraw:" << endl;
cin >> withdraw;
if (withdraw > balance)
cout << "Sorry you don't have enough money to withdraw" << endl;
else if (withdraw <= 0)
cout << "sorry amount can not be zero or negative" << endl;
else
balance = withdrawSum(balance, withdraw);
cout << "You Withdraw :" << withdraw << endl;
cout << "Your newbalance is :" << endl;
cout << balance<<endl;
cout << " PRESS 4 TO MAKE A NEW TRANSACTION AND PRESS 5 TO EXIT?" << endl;
cin >> answer;
if (answer == 4 || answer == 4)
return userinput();
else if (answer == 5 || answer == 5)
return;
else
cout << "Please Enter a Valid choice" << endl;
return;
}
cout << "Enter Your Choice:" << endl;
cin >> choice;
this is messed up because firstly userinput returns void() so why do it like this?
More importantly, everytime you call userinput(), it resets your balance back to zero.