So I know to make a deposit to the balance, which add ups what is the balance to i have add.

When i run the deposit function, its work well in some ways. If balance(text file) has the value 10, add i addSum 20, the balance will become 30, same as the text file will become 30. so its work well to add positive number.

Code:

double deposit(double balance)

{

double addSum = 0;

system("CLS");
cout<< "Welcome to deposit."<<endl;
cout<<"Enter a sum you wish to add to your account:";

fstream myfile;
myfile.open ("money.txt");

cin>> addSum;

balance = addSum + balance;

myfile << balance;

cout << balance << '\n';

system("CLS");
return balance;

}

When I withdraw from 30 which is the balance, then i takeSum, for example i take away 30. The balance will become 30 - 30 = 0
When i make another withdraw from example -150, it will be -150.

Which shows correct.

But when i make a deposit from -150 and i addSum 130, the balance shows -500, and it should had been -20.

Code:

double withdraw(double balance)

{
double takeSum = 0;

system("CLS");
cout<< "Welcome to withdraw."<<endl;
cout<<"Enter a sum you wish to take away from your account:";