Im have trouble complete on what i have. Looking for some idea's I'm getting a exit error and don't know what to do? Please Help

// This is a program that is an ATM.
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;

void welcome();
void menu();
void amountDeposit ();
void amountWithdrawal();


int main ()

{ 
	char choice;
	
	double balance = 800,
		   deposit;

	welcome();
do 
{
	
	menu();
	cin >> choice;
	while (choice < 'A' || choice > 'C')
	{
		cout << " Please make a choice in the range";
		cout << " of A through B:";
		cin >> choice;
	}
	switch (choice)
	{
		case 'a' :
		case 'A' : exit();
				   break;
		case 'b' :
		case 'B' : amountDeposit();
				   break;
		case 'c' :	
		case 'C' : amountWithdrawal();
				   break;
	}
} while ( choice != 'B');

return 0;
}

	
 void welcome()
{ 
	cout << "- - - - - - - - - - - - - - - - - - -" << endl;
	cout << "-	 Welcome to DDJ'S ATM Servies    -" << endl;
	cout << "-	Please follow the instructions   -" << endl;
	cout << "-	    to access you account        -" << endl;
	cout << "- - - - - - - - - - - - - - - - - - -" << endl;
	system ("PAUSE");
	system ("cls");

}

void menu()

{
	cout << "What would you like to do?" << endl;
	cout << "A. Exit the program" << endl;
	cout << "B. Make a deposit" << endl;
	cout << "C. Make a withdrawal" << endl;
	
}

	
void amountDeposit()

{
	double deposit;
	cout << "How much would you like to deposit?" << endl;
	cin >> deposit;
}

void amountWithdrawal()

{ 
	double withdrawal;
	cout << "How much would you like to withdrawal?" << endl;
	cin >> withdrawal;
}
void exit ()

{
	cout << "Please come again.";
}

Recommended Answers

All 8 Replies

Please use code-tags.....

Try This.....Works fine for me...

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <iostream>


using namespace std;

void main()
{
int choice, a;
float money,m;

void deposite();
void withdraw();
//int func1();


cout<<"Student ID : TATA_12345"<<endl;
cout<<"NAME : RATAN TATA"<<endl;
cout<<"(1) DEPOSITE MONEY"<<endl;
cout<<"(2) WITHDRAW MONEY"<<endl;
cout<<"(3) FIND THE ACCOUNT BALANCE"<<endl;

cout<<"Enter your choice : ";
cin>>choice; /*read the choice*/

switch (choice)
{
case 1:
deposite(); /*to deposite money*/

break;

case 2:
withdraw(); /*to withdraw money*/

break;

case 3:  /*to see the balance*/
cout<<endl<<"This facility is not currently available"<<endl;
break;

default: /*if choice is not valid*/

cout<<"ERROR// PLEASE TRY AGAIN";
exit(1);
}
getch();
}

void deposite()
{
float money;
cout<<endl<<"Enter the amount of money to be deposited(dollars.cents):";
cin>>money; /*read the amount to be deposited*/

if(money>0)
{
cout<<endl<<"$"<<money<<" has been deposited in your account"<<endl;
}
else
cout<<endl<<"Please enter valid amount......."<<endl;
}
void withdraw()
{
long int rem,f,t,e;
long int mon;
cout<<"Enter the amount of money to be withdrawn: ";
cin>>mon; /*read the amount to be withdrawn*/

if(mon>=20)
{
if(mon!=30)
{
f=mon/50; /*decides the notes of $50*/
rem=mon%50;
if(rem!=20)
{
if (rem==10||rem==30)
{
f-=1;
rem+=50;
}
}
t=rem/20; /*decides the notes of $20*/
e=rem%20;
if(e==0)
{
cout<<endl<<"Nos. of 50$ note : "<<f;
cout<<endl;
cout<<"Nos. of 20$ note : "<<t<<endl;
cout<<"TOTAL AMOUNT : "<<mon<<endl;
}
else
cout<<endl<<"This amount is not possible... Please try again"<<endl;
}
else /*if amount is not possible*/
{
cout<<endl;
cout<<"This amount is not possible... Please try again"<<endl;
}
}
else
{
cout<<endl;
cout<<"This amount is not possible... Please try again"<<endl;
}
}
commented: Do not fix nor write answers to problems. And always FORMAT your code! -2

Please use code-tags.....Sorry ignore my previous post....

Try This.....Works fine for me...You forgot to define the function exit();......

// This is a program that is an ATM.
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;

void welcome();
void menu();
void amountDeposit ();
void amountWithdrawal();
void exit();


int main ()

{ 
char choice;

double balance = 800,
deposit;

welcome();
do 
{

menu();
cin >> choice;
while (choice < 'A' || choice > 'C')
{
cout << " Please make a choice in the range";
cout << " of A through C:";
cin >> choice;
}
switch (choice)
{
case 'a' :
case 'A' : exit();
break;
case 'b' :
case 'B' : amountDeposit();
break;
case 'c' :  
case 'C' : amountWithdrawal();
break;
}
} while ( choice != 'B');

return 0;
}


void welcome()
{ 
cout << "- - - - - - - - - - - - - - - - - - -" << endl;
cout << "-     Welcome to DDJ'S ATM Servies -" << endl;
cout << "-    Please follow the instructions -" << endl;
cout << "-     to access you account -" << endl;
cout << "- - - - - - - - - - - - - - - - - - -" << endl;
system ("PAUSE");
system ("cls");

}

void menu()

{
cout << "What would you like to do?" << endl;
cout << "A. Exit the program" << endl;
cout << "B. Make a deposit" << endl;
cout << "C. Make a withdrawal" << endl;

}


void amountDeposit()

{
double deposit;
cout << "How much would you like to deposit?" << endl;
cin >> deposit;
}

void amountWithdrawal()

{ 
double withdrawal;
cout << "How much would you like to withdrawal?" << endl;
cin >> withdrawal;
}
void exit ()

{
cout << "Please come again.";
}

Im have trouble complete on what i have. Looking for some idea's I'm getting a exit error and don't know what to do? Please Help

With what? Do you have a problem? Did you tell us what that problem is? If you did, I missed it somewhere in the explanation.

Please use [code] tags.....

Why? If you don't format anything, it looks the same with or without CODE tags. Unreadable. So always format your code

Also, here we don't post answers to questions. We help them find their own answers. They learn more.

commented: Yes! +20
commented: Not sure what the down votes were about. This post seems good to me. +11

okay thanks for the help. that was stupid of me. Now my problem is i can't get my switch to call out my funtions. any ideas?

The lines below are probably causing the issue...your do while loop is not set up that great...also you are asking for the same input twice (Unnecessary)...
you ask for choice input here

cin >> choice;
while (choice < 'A' || choice > 'C')

and here

cout << " Please make a choice in the range";
cout << " of A through B:";
cin >> choice;

If you delete your do while loop, you will notice it runs fine....In other words re-think and redo you looping system...:)

Thanks again for the help. I ended up figureing it out. My next problem is i need to muliples of $20 and this is what i have

// This is a program that is an ATM.
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;

void welcome();
void menu();
void amountDeposit ();
void amountWithdrawal();
void exit();


int main ()

{
char choice;

double balance = 800,
	   deposit;

welcome();
do 
{

menu();
cin >> choice;
while (choice < 'A' || choice > 'C')
{
cout << " Please make a choice in the range";
cout << " of A through C:";
cin >> choice;
}
switch (choice)
{
case 'a' :
case 'A' : exit();
break;
case 'b' :
case 'B' : amountDeposit();
break;
case 'c' :	
case 'C' : amountWithdrawal();
break;
}
} while ( choice != 'A');




return 0;
}


void welcome()
{ 
cout << "- - - - - - - - - - - - - - - - - - -" << endl;
cout << "-	 Welcome to DDJ'S ATM Servies    -" << endl;
cout << "-	Please follow the instructions   -" << endl;
cout << "-	 to access you account           -" << endl;
cout << "- - - - - - - - - - - - - - - - - - -" << endl;
system ("PAUSE");
system ("cls");

}

void menu()

{
cout << "What would you like to do?" << endl;
cout << "A. Exit the program" << endl;
cout << "B. Make a deposit" << endl;
cout << "C. Make a withdrawal" << endl;

}


void amountDeposit()

{
double deposit;

cout << "How much would you like to deposit? $"; 
cin >> deposit;
if ( deposit >=1000)
{
	cout << "Only able Deposit Maximum of $1000.00 Try Again" << endl;
	cin >> deposit;
}
system ("PAUSE");
system ("cls");


}

void amountWithdrawal()

{ 
double withdrawal;
cout << "How much would you like to withdrawal? $";
cin >> withdrawal;

if ( withdrawal >=500)
{
	cout << "Only able withdrawal Maximum of $500.00. Try Again" << endl;
	cin >> withdrawal;
}
if ( withdrawal= withdrawal % 20)
{
	cout << "Withdrawal Must be a multiple of $20. Try Again" << endl;
	cin >> withdrawal;
}


system ("PAUSE");
system ("cls");
}
void exit ()

{
cout << "Please come again.\n";
}

So i have continued from my last post and im completely screwed up. Things that i have tried to add is to keep a TOTAL BALANCE and i still need some help on the multipule of 20 withdrawal.

// This is a program that is an ATM.
#include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;

// These are function prototypes
void welcome();
void menu();
double amountDeposit ();
void amountWithdrawal();
double finalBalance ();
void exit();

// This the main function that will operate all other funtions.
int main ()

{
char choice;
double deposit,totalBalance;
	  
welcome();
do 
{

menu();
cin >> choice;
while (choice < 'A' || choice > 'C')
{
cout << " Please make a choice in the range";
cout << " of A through C:";
cin >> choice;
}
switch (choice)
{
case 'a' :
case 'A' : exit();
break;
case 'b' :
case 'B' : amountDeposit();
		   cout << "You deposited $ " << amountDeposit() << "." <<  finalBalance () << "." << endl;
           break;
case 'c' :	
case 'C' : amountWithdrawal();
break;
}
} while ( choice != 'A');




return 0;
}


// Function is the welcome menu.
void welcome()
{ 
cout << "- - - - - - - - - - - - - - - - - - -" << endl;
cout << "-	 Welcome to DDJ'S ATM Servies    -" << endl;
cout << "-	Please follow the instructions   -" << endl;
cout << "-	 to access you account           -" << endl;
cout << "- - - - - - - - - - - - - - - - - - -" << endl;
system ("PAUSE");
system ("cls");

}

// Function is the welcome Main menu that gives you the choices.
void menu()

{
cout << "What would you like to do?" << endl;
cout << "A. Exit the program" << endl;
cout << "B. Make a deposit" << endl;
cout << "C. Make a withdrawal" << endl;

}


// Function will run the deposits.
double amountDeposit(double deposit)

{
	
cout << "How much would you like to deposit? $"; 
cin >> deposit;
if ( deposit >=1000)
{
	cout << "Only able Deposit Maximum of $1000.00 Try Again" << endl;
	cin >> deposit;
}

 return (deposit);
system ("PAUSE");
system ("cls");

}

// Function will run the withdrawals.
void amountWithdrawal()

{ 
double withdrawal;
cout << "How much would you like to withdrawal? $";
cin >> withdrawal;

if ( withdrawal >=500)
{
	cout << "Only able withdrawal Maximum of $500.00. Try Again" << endl;
	cin >> withdrawal;
}
if ( withdrawal= withdrawal % 20)
{
	cout << "Withdrawal Must be a multiple of $20. Try Again" << endl;
	cin >> withdrawal;
}


system ("PAUSE");
system ("cls");
}

double finalBalance (double totalBalance)
{
	double balance = 800,
	       totalbalance;
	totalBalance = balance + amountDeposit();
	return (totalbalance);
}
	

// This is the exit funtion
void exit ()

{
cout << "Please come again.\n";
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.