There are few errors in your source code that need correctifon.
The function exit() in the quit() function, The variable answer is declared inside the do-while loop, but it is being used outside of the loop in the while statement. The variable answer is declared inside the do-while loop, but it is being used outside of the loop in the while statement.
Following code are helpful to you it's fixed errors.
//Libraries I need
#include <iostream>
#include <stdlib.h>
#include <cstdlib>
using namespace std;
//Functions
void showBallance();
void dePosit(double amount);
void WithDraw(double amount);
void quit();
//Main Variable(The user's ballance)
double ballance = 0.00;
int main()
{
int answer; // Moved the variable outside the do-while loop
do {
cout << "Choose what you want me to do:\n";
cout << "1. Show Ballance\n";
cout << "2. Deposit\n";
cout << "3. Withdraw\n";
cout << "4. Exit\n";
cin >> answer;
switch (answer) {
case 1:
showBallance();
break;
case 2:
double amount;
cout << "How much money do you want to deposit? (Max: $400)\n";
cin >> amount;
if (amount > 400)
{
cout << "You can't deposit more money than maximum. Try again.";
cin >> amount;
}
else {
dePosit(amount);
}
break;
case 3:
double yoanswer;
cout << "How many money do you want to withdraw from your bank account? (Your ballance currently is " << ballance << ")";
cin >> yoanswer;
WithDraw(yoanswer); // Fixed the function call
break;
case 4:
quit();
break;
default:
cout << "I can't understand you. Goodbye.";
quit();
break;
}
} while (answer != 4);
return 0;
}
void showBallance()
{
cout << "Your ballance is " << ballance << ". If you wish to add more money to your bank account there is an option to deposit.\n";
// Removed "return 0;" since the function is of type "void"
}
void dePosit(double amount)
{
ballance += amount;
cout << "Your ballance currently is " << ballance << ".\n";
// Removed "return 0;" since the function is of type "void"
}
void WithDraw(double amount)
{
ballance -= amount;
if (ballance < 0)
{
cout << "You can't withdraw more money that is on your bank account.\n";
}
// Removed "return 0;" since the function is of type "void"
}
void quit()
{
exit(0); // Added parameter to exit function
}