dudenell
2007-12-19 04:22:33 UTC
* Program Name: Lab 12
* Author: Daniel Carr
* Date: 12 December 2007
* Course/Section: CSC-110-001
* Program Description: This program will tell what coins to give out for
* any amount of change from 1 cent to 99 cents.
*
*
**********************************************************************/
/************************** Compiler Directives **********************/
#include
using namespace std;
/*********************** Global Data Declarations ********************/
//None in this program.
/************************** Function Prototypes **********************/
//Sorts two numbers in ascending order
void input(int money);
int Calculatechange(int change);
int Calculatechange(int change);
void computecoin ( int& amount,int& coins, int denomiation);
void Output(int change, int quarters, int dimes, int nickles, int pennies);
/**********************************************************************
* Function Name: main
* Author: Daniel Carr
* Date: 8 November 2007
* Function Description:
*
* Pseudocode:
* Level 0
* -------
*
*
*
* Level 1
* -------
*
**********************************************************************/
int main()
{
//Local variables
int money; //First user-entered number
int change; //Second user-entered number
/*************** Begin main Function Executables *****************/
//Variables
int quarters;
int dimes;
int pennies;
int nickles;
//Call function input
input(money);
//Call the function calculate
Calculatechange(change);
//Call function output
Output( change, quarters, dimes, nickles, pennies);
//Indicate to OS successful termination of program
return 0;
} //End main
/**********************************************************************
* Function Name: Input Money
* Author: Daniel Carr
* Date: 8 November 2007
* Function Description:
*
*
* Pseudocode:
* Level 0
* -------
* Enter amount of Money
*
* Level 1
* -------
* Enter amount of money
* Display "Enter amount of money (1-99)--->"
* Input Money
*
**********************************************************************/
void input(int money)
//void inputmoney(float& x, //INOUT: First number to be sorted
// float& y) //INOUT: Second number to be sorted
{
//Local variables
cout << "Enter amount of money (1-99)--->: ";
cin >> money;
} //End Input money
/**********************************************************************
* Function Name: Calculate Change
* Author: Daniel Carr
* Date: 8 November 2007
* Function Description: Calculate quarters, dimes, nickles, and pennies
*
*
* Pseudocode:
* Level 0
* -------
* Calculate Change
*
* Level 1
* -------
* Calcualte change
* Compute Quarters
* Compute Dimes
* Compute Nicklets and Pennies
* Level 2
* -------
* Compute Quarters
* Compute coin with Quarters, Change, and Q
* Compute Dimes
* Compute coin with Dimes, Change, and D
* Compute Nickles and Pennies
* Compute coin with Nickes Change and N,
*
*
*
*
*
*
*
**********************************************************************/
int Calculatechange(int change)
{
//constants
const int q=25;
const int d=10;
const int n=5;
//arguements
int amount;
int denomiation;
int coins;
//Call the function computer coin
computecoin(amount,coins,denomiation);
return coins;
}
/**********************************************************************
* Function Name: Compute Coin
* Author: Daniel Carr
* Date: 8 November 2007
* Function Description: compute number of coin and amount left
*
*
* Pseudocode:
* level 0
* -------
* Compute number of coins and amount left
* level 1
* -------
* Compute number of coins and amount left
* coin=amount/demination
* amount = amount%demination
*
**********************************************************************/
void computecoin ( int& amount,int& coins, int denomiation)
{
//Constistants
//Variables
//Arguements
coins = amount/denomiation;
amount= amount%denomiation;
amount %=denomiation;
}
/**********************************************************************
* Function Name: Display Change
* Author: Daniel Carr
* Date: 8 November 2007
* Function Description: compute number of coin and amount left
*
*
* Pseudocode:
* level 0
* -------
* Display Change
* level 1
* -------
* Display Change
* display Change& "coints can be given" EOL
* display "-----------------------" EOL
* display quarters & "Quarter(s)" EOL
* display dimes & "Dimes(s)" EOL
* display nickles & "Nickles(s) EOL
* display pennies & "Pennie(s) EOL
*
**********************************************************************/
void Output(int change, int quarters, int dimes, int nickles, int pennies)
{
//Aruments
//Consistants
//Variables
cout << change << "coins can be given" << endl;
cout << "-------------------------------------" << endl;
cout << quarters << "quarter(s)" << endl;
cout << dimes << "dimes(s)" << endl;
cout << nickles << "Nickle(s)" << endl;
cout << pennies << "Pennie(s)" << endl;
;}