#include #include using namespace std; int main() { int quarters {0}; int dimes {0}; int nickels {0}; int pennies {0}; cout << "How many quarters do you have?\n"; cin >> quarters; if (!cin) { cerr << "Sorry, that wasn't a valid whole number.\n"; return EXIT_FAILURE; } if (quarters < 0) { cerr << "Sorry, you cannot have negative quarters.\n"; return EXIT_FAILURE; } cout << "How may dimes do you have?\n"; cin >> dimes; if (!cin){ cerr << "Sorry, that wasn't a valid whole number.\n"; return EXIT_FAILURE; } if (dimes < 0) { cerr << "Sorry, you cannot have negative dimes.\n"; return EXIT_FAILURE; } cout << "How many nickels do you have?\n"; cin >> nickels; if (!cin){ cerr << "Sorry, that wasn't a valid whole number.\n"; return EXIT_FAILURE; } if (nickels < 0){ cerr << "Sorry, you cannot have negative nickels.\n"; return EXIT_FAILURE; } cout << "How many pennies do you have?\n"; cin >> pennies; if (!cin){ cerr << "Sorry, that wasn't a valid whole number.\n"; return EXIT_FAILURE; } if (pennies < 0){ cerr << "Sorry, that wasn't a valid whole number.\n"; return EXIT_FAILURE; } double money {quarters * 0.25 + dimes * 0.10 + nickels * 0.05 + pennies * 0.01}; cout << "You have $" << money << ".\n"; return EXIT_SUCCESS; }