1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
//Coin Calculator
//Determines how much money is in an amount of coins
#include <iostream>
#include <string>
using namespace std;
enum CoinValue { PENNY = 1, NICKEL = 5, DIME = 10, QUARTER = 25, HALF = 50, DOLLAR = 100, NUM_VALUES = 6};
float calculateValue(CoinValue coin, int numCoins);
float output(string coin, CoinValue value);
int main(){
float money;
cout << "\t\tWelcome to Coin Calculator!\n\n";
money = output("Pennies", PENNY);
money += output("Nickels", NICKEL);
money += output("Dimes", DIME);
money += output("Quarters", QUARTER);
money += output("Halves", HALF);
money += output("Dollars", DOLLAR);
money /= 100;
cout << "\nYour total money is: $" << money << endl;
return 0;
}
float calculateValue(CoinValue coin, int numCoins){
float value = coin * numCoins;
return (value);
}
float output(string coin, CoinValue value){
int response;
float money;
cout << coin << ": ";
cin >> response;
money = calculateValue(value, response);
return (money);
}
|