VB icon

ATM Simulation

Email
Submitted on: 1/2/2015 7:06:00 PM
By: Kevin Oliver  
Level: Beginner
User Rating: By 4 Users
Compatibility: C++ (general), Microsoft Visual C++
Views: 4
 
     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!
				
//**************************************
// 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
//**************************************

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


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


 There are no comments on this submission.
 

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.