MegaloJntariac
10+ year member
Mr.SQ
Here is where I am at now. I can get it to execute, but its:
- Not taking the fee out and posting it
- Its only changing bills but not with the coins, and if i input just a decimal it shows the coins, so i need it to do both.
Win32 Console file
Here is what I am trying to get it to do:
- Prompts to ask for Check amount
- You Input check amount, if it is more than 1000 it loops back and asks you again
- at this point it should take a fee out based on the amount, also it will tell you how much the fee was
- now it should take whats left after the fee and change that into bills and coins, but our instructor wanted us to use an overload function to separate the bills and coins but using the same name.
- Not taking the fee out and posting it
- Its only changing bills but not with the coins, and if i input just a decimal it shows the coins, so i need it to do both.
Win32 Console file
Code:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void change(double, int&, int&, int&, int&, int&, int&);
void change(double, int&, int&, int&, int&);
bool validFee(double a)
{
return (a <= 1000);
} // end Bool
void main()
{
int quar=0, dime=0, nick=0, penn=0, hunds = 0, fifts= 0, twents = 0, tens = 0, fives = 0, ones = 0;
double a; //price of check < $1000.01
do
{
cout<<"Enter Check Amount: ";
cin>>a;
}
while (! validFee(a));
cout<<"Check Amount: "<<a<<endl;
change(a, hunds, fifts, twents, tens, fives, ones);
change(a, quar, dime, nick, penn);
}//endmain
double fee(double& a)
{
if (a>=0 && a<=100)
{
a = a - 5;
cout<<" Cashing Fee : $5.00"<<endl;
return a;
} // ends if
if (a>100 && a<=500)
{
a = a - 15;
cout<<" Cashing Fee :$15.00"<<endl;
return a;
} // ends if
if (a>500 && a<=1000)
{
a = a - 25;
cout<<" Cashing Fee :$25.00"<<endl;
return a;
} // ends if
}//end fee
void change(double a,int& h,int& f,int& tw,int& te,int& fi,int& o)
{
int c = static_cast<int>(a);
int hunds, fifts, twents, tens, fives, ones;
h=c/100;
c%=100;
f=c/50;
c%=50;
tw=c/25;
c%=25;
te=c/10;
c%=10;
fi=c/5;
c%=5;
o=c/1;
hunds = (h) * 100;
fifts = (f) * 50;
twents = (tw) * 20;
tens = (te) * 10;
fives = (fi) * 5;
ones = (o) * 1;
cout<<"Denominations Dispensed:"<<setw(15)<<endl;
cout<<"------------------------"<<setw(15)<<endl;
cout<<" # Amount"<<setw(15)<<endl;
cout<<" ------ -------- "<<setw(10)<<endl;
if(h>0)
cout<<"Hundreds: "<<setw(15)<<h<<setw(10)<<hunds<<endl;
if(f>0)
cout<<"Fifties: "<<setw(15)<<f<<setw(10)<<fifts<<endl;
if(tw>0)
cout<<"Twenties: "<<setw(15)<<tw<<setw(10)<<twents<<endl;
if(te>0)
cout<<"Tens: "<<setw(15)<<te<<setw(10)<<tens<<endl;
if(fi>0)
cout<<"Fives: "<<setw(15)<<fi<<setw(10)<<fives<<endl;
if(o>0)
cout<<"Ones: "<<setw(15)<<o<<setw(10)<<ones<<endl;
} // end change bills
void change(double a,int& q,int& d,int& n,int& p)
{ double chg = 1.00 - a;
int quar, dime, nick, penn;
int c = static_cast<int> (chg*100);
q=c/25;
c%=25;
d=c/10;
c%=10;
n=c/5;
p=c%5;
quar = (q) * 25;
dime = (d) * 10;
nick = (n) * 05;
penn = (p) * 01;
if(q>0)
cout<<"Quarters: "<<setw(15)<<q<<setw(10)<<quar<<endl;
if(d>0)
cout<<"Dimes: "<<setw(15)<<d<<setw(10)<<dime<<endl;
if(n>0)
cout<<"Nickels: "<<setw(15)<<n<<setw(10)<<nick<<endl;
if(p>0)
cout<<"Pennies: "<<setw(15)<<p<<setw(10)<<penn<<endl;
} // end change coins
- Prompts to ask for Check amount
- You Input check amount, if it is more than 1000 it loops back and asks you again
- at this point it should take a fee out based on the amount, also it will tell you how much the fee was
- now it should take whats left after the fee and change that into bills and coins, but our instructor wanted us to use an overload function to separate the bills and coins but using the same name.
