D
dan
can someone tell me how to have balance add the initial 10 dollars
just one time and not every time
thanks
int main()
{
double initial = 10, transaction;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision (2); // for 2 decimal place, because that is what
money uses
cout << "************Enter 0.00 to quit this
program************\n\n";
cout << "Initial balance: " << initial;
cout << endl;
double balance = 0;
double penalty = 0;
double invalid = 0;
do
{
cout << "\nEnter transaction amount: ";
cin >> transaction;
balance = balance + transaction + initial;
invalid = balance - transaction - initial;
if (balance >= 0)
{
cout << "Balance: " << balance;
cout << endl;
}
if ((balance < 0 && balance > -100))
{
cout << "Overdraw fee: $10.00\n";
penalty = balance - initial - 10;
cout << "Balance: " << penalty;
cout << endl;
}
if (balance < -100)
{
cout << "Insufficient funds to complete transaction.\n";
cout << "Balance: " << invalid;
cout << endl;
}
} while (transaction != 0.00); //sentinel value
cout << endl;
cout << "End of day balance: " << balance;
cout << endl << endl;
system ("pause");
return EXIT_SUCCESS;
}
just one time and not every time
thanks
int main()
{
double initial = 10, transaction;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision (2); // for 2 decimal place, because that is what
money uses
cout << "************Enter 0.00 to quit this
program************\n\n";
cout << "Initial balance: " << initial;
cout << endl;
double balance = 0;
double penalty = 0;
double invalid = 0;
do
{
cout << "\nEnter transaction amount: ";
cin >> transaction;
balance = balance + transaction + initial;
invalid = balance - transaction - initial;
if (balance >= 0)
{
cout << "Balance: " << balance;
cout << endl;
}
if ((balance < 0 && balance > -100))
{
cout << "Overdraw fee: $10.00\n";
penalty = balance - initial - 10;
cout << "Balance: " << penalty;
cout << endl;
}
if (balance < -100)
{
cout << "Insufficient funds to complete transaction.\n";
cout << "Balance: " << invalid;
cout << endl;
}
} while (transaction != 0.00); //sentinel value
cout << endl;
cout << "End of day balance: " << balance;
cout << endl << endl;
system ("pause");
return EXIT_SUCCESS;
}