Circuit Negma

C++, C, VB.NET, PCB, Electronics, Circuit Design

Cashier – ver 2.0

Posted by Circuit Negma on March 10, 2006


/*
 *  Copyright © 1997-2003 Metrowerks Corporation.  All Rights Reserved.
 *	
 *  Description: this program computes the number of half-dollars,
 *		 quarters, dimes, nickles and pennies in a given
 *		 amount of change in cents by the customer.
 *
 *  Created By    : Circuit Negma
 *
 *  Date	  : March 10, 2006
 *
 *  File	  : cashier2.cpp
 *
 *  Version	  : ver 2.0
 */
 
 	// Header Files
#include <iostream>
using namespace std;

	// Declare Constants
const int half_dollar     = 50;
const int quarters	  = 25;
const int dimes		  = 10;
const int nickles	  = 5;

int main()
{
	// Declare Variables
	int changes;	// user input data
	
	// Ask the user to enter Data
	cout << "Please, Enter change in cents: ";
	cin >> changes;
	
	// Confirm data with the user
	cout << "You gave the cashier " << changes << " cents." << endl;
	
	// Perform cal. and Print out the results
	cout << "The number of half-dollars to be returned are " << changes / half_dollar << endl;
	changes = changes % half_dollar;
	
	cout << "The number of quarters to be returned are " << changes / quarters << endl;
	changes = changes % quarters;
	
	cout << "The number of dimes to be returned are " << changes / dimes << endl;
	changes = changes % dimes;
	
	cout << "The number of nickles to be returned are " << changes / nickles << endl;
	changes = changes % nickles;
	
	cout << "The number of pennies to be returned are " << changes << endl;
	
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: