// Nathanael Schwartz CS1A Chapter 4, P. 221, #8
//
/*******************************************************************************
*
* COUNT CHANGE
* _____________________________________________________________________________
* This program asks the user to enter the number of pennies, nickels, dimes,
* and quarters, and calculates the total amount. If the total equals exactly
* one dollar, the user wins the game. Otherwise, the program informs the user
* if the amount is less than or greater than one dollar.
* _____________________________________________________________________________
* INPUT
* pennies : Number of pennies
* nickels : Number of nickels
* dimes : Number of dimes
* quarters : Number of quarters
*
* OUTPUT
* total : Total amount of coins
*
******************************************************************************/
#include <iostream>
using namespace std;
int main() {
// Declare variables
int pennies; // INPUT - Number of pennies
int nickels; // INPUT - Number of nickels
int dimes; // INPUT - Number of dimes
int quarters; // INPUT - Number of quarters
double total; // OUTPUT - Total value of coins
// Input values from user
cout << "Enter the number of pennies: \n";
cin >> pennies;
cout << "Enter the number of nickels: \n";
cin >> nickels;
cout << "Enter the number of dimes: \n";
cin >> dimes;
cout << "Enter the number of quarters: \n";
cin >> quarters;
// Calculate total value of coins
total = pennies * 0.01 + nickels * 0.05 + dimes * 0.10 + quarters * 0.25;
// Output results
if (total == 1.00)
cout << "Congratulations! The total is exactly one dollar. You win!\n";
else if (total < 1.00)
cout << "The total is less than one dollar.\n";
else
cout << "The total is more than one dollar.\n";
return 0;
}