I cannot get this to stop giving error message at line 69 about the implementaion of display_balances function. Why is this function not working? Or my program in general? // Will 2/11/05
// Assignment 2

Attachments
// 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;}

What a display of putrid formatting! Kudos for digging your own grave by trying to be concise. Here's your program with better formatting. Notice how the error is painfully obvious now (even without my red highlighting ;)):

// 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;
}

Some people just don't seem to get it. There are de facto standards for formatting for a reason. Over the decades, everyone found out what worked best and what didn't.

Thanks for your help. I appriciate it.

What a display of putrid formatting! Kudos for digging your own grave by trying to be concise. Here's your program with better formatting. Notice how the error is painfully obvious now (even without my red highlighting ;)):

// 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;
}

Some people just don't seem to get it. There are de facto standards for formatting for a reason. Over the decades, everyone found out what worked best and what didn't.

This article has been dead for over six months. Start a new discussion instead.