Important alert: (current site time 11/1/2014 7:12:19 AM EDT)
 

VB icon

ATM Simulation

Email
Submitted on: 9/28/2001 11:22:32 AM
By: Kevin Oliver  
Level: Beginner
User Rating: By 4 Users
Compatibility: C++ (general), Microsoft Visual C++
Views: 13146
(About the author)
 
     This was originally written for rent-a-coder, but since the buyer never accepted any of the bids I decided to post it here. It's really limited but it shows how to use functions and if... else loops. It also shows how to used enum to make a simple menu. You could make a menu without enum, but enum makes it easier to code and to maintain
 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
//INCLUDE files for :ATM Simulation
//**************************************
iostream.h
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
//**************************************
// Name: ATM Simulation
// Description:This was originally written for rent-a-coder, but since the buyer never accepted any of the bids I decided to post it here. It's really limited but it shows how to use functions and if... else loops. It also shows how to used enum to make a simple menu. You could make a menu without enum, but enum makes it easier to code and to maintain
// By: Kevin Oliver
//
// Returns:0
//
// Assumes:This program is really limited but it shows how to use functions and if... else loops. It also shows how to used enum to make a simple menu. You could make a menu without enum, but enum makes it easier to code and to maintain
//
//This code is copyrighted and has// limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=2586&lngWId=3//for details.//**************************************

#include <iostream.h>
void fdeposit()
{
	cout << "Enter the amount to be deposited\n";
	cout << "$";
float amountdeposited = 0.00;
	cin >> amountdeposited;
	cout << "\n You deposited $" << amountdeposited << "\n";
}
void fwithdraw()
{
	cout << "Enter the amount to be withdrawn\n";
cout << "$";
	int amountwithdrawn = 0;
	cin >> amountwithdrawn;
	int temp = 0;
	int numberof50s = 0;
	int numberof20s = 0;
	temp = (amountwithdrawn % 10);
	
	if (temp != 0.00)
	{
		cout << "That amount can not be withdrawn\n";
		return;
	}
	if (amountwithdrawn < 20)
	{
		cout << "That amount can not be withdrawn\n";
		return;
	}
	
	temp = amountwithdrawn / 10;
	
	if (temp % 5 == 0)
	{ 
		numberof50s = (temp / 5);
	}
	
	else
	{
		if (temp % 2 == 0)
		{
		numberof20s = (temp / 2);
		}
	}
	if ((temp % 5)%2 == 0) 
	{
		numberof50s = (temp / 5);
		numberof20s = ((temp %5)/2);
	}
	 
	cout << numberof50s << " $50 bills withdrawn\n";
	cout << numberof20s << " $20 bills withdrawn\n";
	cout << "$" << amountwithdrawn << " withdrawn\n";	
	
}
int main()
{
	cout << "ID = \t C0103060x\n";
	cout << "NAME = \t Claudio A";
	enum menuoptions { deposit = 1, withdraw = 2, balance = 3};
	cout << "Press the corresponding number to access an option\n";
	cout << "1. Deposit money\n";
	cout << "2. Withdraw money\n";
	cout << "3. Balance Inquiry\n";
	int choice = 0;
	cin >> choice;
	
	if (choice == deposit)
		fdeposit();
	
	if (choice == withdraw)
		fwithdraw();
	if (choice == balance)
		cout << "Sorry, that option is not yet available!\n";
 
	return 0;
}


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

7/10/2002 10:22:36 AMTrista

I finally understood how an ATM transaction is broken down by way of code! Thanks!
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.