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 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void change(double, int&, int&, int&, int&, int&, int&);
void change(int, int&, int&, int&, int&);
int main() //main
{
int hund=0, fifty=0, twenty=0, ten=0, five=0, one=0, qtr=0, dm=0, nk=0, pn=0;
double amt; //change<=$1000
cout<<"Enter check amount: ";
cin>>amt;
change(amt, hund, fifty, twenty, ten, five, one);
change(amt, qtr, dm, nk, pn);
cout<<hund<<" "<<fifty<<" "<<twenty<<" "<<ten<<" "<<five<<" "<<one<<" "<<endl;
cout<<qtr<<" "<<dm<<" "<<nk<<" "<<pn<<" "<<endl;
}//end main
void change(double a, int&h, int&f, int&w, int&t, int&v, int&o) //bills
{
double chg = a;
int c = static_cast<int> (chg*1);
h=c/100;
c%=100;
f=c/50;
c%=50;
w=c/20;
c%=20;
t=c/10;
c%=10;
v=c/5;
c%=5;
o=c;
}
void change(int a, int&q, int&d, int&n, int&p) //coins
{
int chg = a%1;
int c = static_cast<int> (chg*100);
q=c/25;
c%=25;
d=c/10;
c%=10;
n=c/5;
c%=5;
p=c;
}
|