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 42 43 44 45 46 47 48
|
#include <iostream>
#include <string>
#include<iomanip>
#include<windows.h>
using namespace std;
int main(){
const int hundredsConst=10000, fiftiesConst=5000, twentiesConst=2000, tensConst=1000;
const int fivesConst=500, onesConst=100, quartersConst=25, dimesConst=10, nickelsConst=5, tab=5;
int hundreds, fifties, twenties, tens, fives, ones, quarters, dimes, nickels, pennies;
int dollarsBeforeDecimal, centsAfterDecimal, moneyInPennies, counter=1;
string name, hundredsEnd, fiftiesEnd, twentiesEnd, tensEnd, fivesEnd, onesEnd, quartersEnd, dimesEnd, nickelsEnd, penniesEnd;
char decimalPoint;
cin >> dollarsBeforeDecimal >> decimalPoint >> centsAfterDecimal;
moneyInPennies = (dollarsBeforeDecimal*100) + (centsAfterDecimal);
hundreds = moneyInPennies/hundredsConst;
moneyInPennies -= hundreds*hundredsConst;
fifties = moneyInPennies/fiftiesConst;
moneyInPennies -= fifties*fiftiesConst;
twenties = moneyInPennies/twentiesConst;
moneyInPennies -= twenties*twentiesConst;
tens = moneyInPennies/tensConst;
moneyInPennies -= tens*tensConst;
fives = moneyInPennies/fivesConst;
moneyInPennies -= fives*fivesConst;
ones = moneyInPennies/onesConst;
moneyInPennies -= ones*onesConst;
quarters = moneyInPennies/quartersConst;
moneyInPennies -= quarters*quartersConst;
dimes = moneyInPennies/dimesConst;
moneyInPennies -= dimes*dimesConst;
nickels = moneyInPennies/nickelsConst;
moneyInPennies -= nickels*nickelsConst;
pennies = moneyInPennies;
return 0;
}
|