I got some help on here earlier (thanks if you are reading) and its looks much better, but it still says sytex error at line 69 sidentifier "display_balances"
Please, what is wrong with this function, or is something else interferring. Thanks. Will
I got some help on here earlier (thanks if you are reading) and its looks much better, but it still says sytex error at line 69 sidentifier "display_balances"
Please, what is wrong with this function, or is something else interferring. Thanks. Will
// Will Urban CS 161 2/11/05
// Assignment 2
#include <iostream>
#include <iomanip>
using namespace::std;
//declare function
void display_menu ();
void get_balances (double& checking, double& savings);
//process functions
void transfer (double& checking, double& savings);
void withdraw (double& checking);
void deposit (double& checking);
void display_balances (double checking, double savings);
enum {TRANSFER = 1, WITHDRAW, CHECK, DEPOSIT, EXIT};
double transfer_amount;
double amount;
double amt;
//main function
int main ()
{
double checking, savings;
int choice;
get_balances (checking, savings);
bool done = false;
do{
display_menu ();
cout << "Enter Choice: ";
cin >> choice;
switch (choice)
{
case TRANSFER:
transfer (checking, savings);
break;
case WITHDRAW:
withdraw (checking);
break;
case CHECK:
withdraw (checking);
break;
case DEPOSIT:
deposit (checking);
break;
case EXIT:
done=true;
break;
} while (done = !true);
}
display_balances (checking, savings);
return 0;
}
//function definitions
void get_balances ( double& checking, double& savings)
{
do
{
cout << "Enter checking balance: ";
cin >> checking;
} while (checking >= 0 );
do
{
cout << "Enter savings balance: ";
cin >> savings;
} while (savings >= 0 );
}
void display_menu ()
{
cout << "Banking options " << endl
<< "1) Transfer " << endl
<< "2) Withdawl " << endl
<< "3) Check written " << endl
<< "4) Deposit " << endl
<< "5) Exit " << endl;
}
//process functions
void transfer (double& checking, double& savings)
{
do {
double transfer_amount;
cout << "Enter transfer amount: ";
cin >> transfer_amount;
} while (!(transfer_amount <= checking));
checking -= transfer_amount;
savings += transfer_amount;
}
void withdraw (double& checking)
{
do {
double amount;
cout << "Enter amount to withdraw: ";
cin >> amount;
} while (amount <= checking);
checking -= amount;
}
void deposit (double& checking)
{
do {
double amt;
cout << "Enter amount to withdraw: ";
cin >> amount;
} while (amt >= 0);
checking += amt;
}
void display_balances (double checking, double savings)
{
cout.setf (ios::fixed | ios::showpoint);
cout.precision (2);
cout << setw (30) << "Check balance: "
<< setw (25) << checking
<< setw (20) << "savings balance: "
<< setw (15) << savings;
}
Okay, I guess the problem wasn't painfully obvious even though I pointed it out to the line! You're trying to terminate your switch statement with a while condition. That's a syntax error. Change this:
} while (done = !true);
}
To this:
}
} while (done = !true);
And pay attention when someone tries to help you next time. By the way, you have other problems, but at least try to solve them on your own before running back here.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.