//Ryan Shahriyarpour CS1A Carl Argila CH4 HW Q:4
//
/*****************************************************************************
*
* Change for a Dollar Game
*
*********************
*
* Create a change-counting game that gets the user to enter the number of
* coins required to make exactly one dollar. The program asks for the number
* of pennies, nickels, dimes, and quarters. If the total value equals one
* dollar, then it will the user. Otherwise, it will show whether the amount is more
* or less than one dollar.
*
* INPUT
* pennies : Number of pennies (1 cent each)
* nickels : Number of nickels (5 cents each)
* dimes : Number of dimes (10 cents each)
* quarters : Number of quarters (25 cents each)
*
* OUTPUT
* Message indicating if player won or the amount difference
*
****************************************************************************/
#include <iostream>
using namespace std;
int main()
{
const int ONE_DOLLAR = 100;
const int PENNY = 1;
const int NICKEL = 5;
const int DIME = 10;
const int QUARTER = 25;
int pennies;
int nickels;
int dimes;
int quarters;
int total;
cout << "Welcome to the Change for a Dollar Game!\n";
cout << "Enter the number of pennies: ";
cin >> pennies;
cout << "Enter the number of nickels: ";
cin >> nickels;
cout << "Enter the number of dimes: ";
cin >> dimes;
cout << "Enter the number of quarters: ";
cin >> quarters;
total = (pennies * PENNY) + (nickels * NICKEL) +
(dimes * DIME) + (quarters * QUARTER);
if (total == ONE_DOLLAR)
{
cout << "Congratulations! You won!\n";
}
else if (total > ONE_DOLLAR)
{
cout << "You have " << (total - ONE_DOLLAR) << " cents too much.\n";
}
else
{
cout << "You have " << (ONE_DOLLAR - total) << " cents too little.\n";
}
return 0;
}