//Amari Mosley CSC5 Chapter 4, P.220 #5
//
/**************************************************************
*
* Computing Change for Dollar
* ____________________________________________________________
* This program will determine if an amount of change is equal
* to, greater than, or less than a dollar.
*
* Computation is based on the conditional operator:
* total = (pennies * 0.01) + (nickels * 0.05) + (dimes * 0.10)
* + (quarters * 0.25)
* ____________________________________________________________
* INPUT
* pennies : Number of pennies entered by user
* nickels : Number of nickels entered by user
* dimes : Number of dimes entered by user
* quarters : Number of quarters entered by user
*
* OUTPUT
* total : Calculated total dollar amount
*
* Displays whether the user won, or if the total was more/less
* than $1.00
*
**************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
// Defining Main Function
int main()
{
// Defining int Variables for counts and double for total
int pennies; // Number of pennies entered by user
int nickels; // Number of nickels entered by user
int dimes; // Number of dimes entered by user
int quarters; // Number of quarters entered by user
double total; // Total value of the coins entered
// Prompting user to enter the number of coins
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;
// Calculating total value of coins
total = (pennies * 0.01) + (nickels * 0.05) + (dimes * 0.10) + (quarters * 0.25);
// Determining game result and displaying message
if (total == 1.00)
{
cout << "Congratulations! You won the game by entering exactly one dollar!" << endl;
}
else if (total > 1.00)
{
cout << "The amount entered was more than one dollar." << endl;
}
else
{
cout << "The amount entered was less than one dollar." << endl;
}
return 0;
}