Circuit Negma

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

Cashier – ver 1.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	  : cashier.cpp
 *
 *  Version	  : ver 1.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 result_half_dollar;	        // hold the number of half dollars
	int result_quarters;	        // hold the number of quarters
	int result_dimes;		// hold the number of dimes
	int result_nickles;		// hold the number of nickles
	int result_pennies;		// hold the number of pennies
	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 the necessary cal.
	result_half_dollar = changes / half_dollar;
	result_quarters	   = (changes % half_dollar) / quarters;
	result_dimes	   = ((changes % half_dollar) % quarters) / dimes;
	result_nickles	   = (((changes % half_dollar) % quarters) % dimes) / nickles;
	result_pennies	   = ((((changes % half_dollar) % quarters) % dimes) % nickles);
	
	// Print out the results
	cout << "The number of half-dollars to be returned are " << result_half_dollar << endl;
	cout << "The number of quarters to be returned are " << result_quarters << endl;
	cout << "The number of dimes to be returned are " << result_dimes << endl;
	cout << "The number of nickles to be returned are " << result_nickles << endl;
	cout << "The number of pennies to be returned are " << result_pennies << 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: