the problem is within this code. When the difference is 1 penny sometimes it bypasses teh decision tree below: "no adjustment necessary" or "adjustment necessary"
coffee the key towards great thoughts
cents_no_decimal = convert_cents(cents);
cout<<cents_no_decimal<<" converted to no decimal"<<endl;
find_change(cents_no_decimal, quarters, dimes, nickels, pennies, a, checksum_1);
//cout<<cents_no_decimal<<endl;
double diff_1 = 0;
diff_1 = cents_no_decimal - checksum_1; //find the offset amt which is the money before the function then after
cout<<"diff_1:"<<diff_1;
//difference = diff_1;
if (diff_1 == 0) {cout<<"no adjustment necessary"<<endl;
cout<<"difference :"<<difference <<endl;}
else if(diff_1==1) {cout<<"adjustment necessary"<<endl;}
//executive function
cout<<endl;
cout<<"continue y/n : ";
cin>>j;
if (j!='y')
{
cout<<"terminating program";
flag = false;
}
cents_no_decimal = convert_cents(cents);
cout<<cents_no_decimal<<" converted to no decimal"<<endl;
find_change(cents_no_decimal, quarters, dimes, nickels, pennies, a, checksum_1);
//cout<<cents_no_decimal<<endl;
double diff_1 = 0;
diff_1 = cents_no_decimal - checksum_1; //find the offset amt which is the money before the function then after
cout<<"diff_1:"<<diff_1;
//difference = diff_1;
if (diff_1 == 0) {cout<<"no adjustment necessary"<<endl;
cout<<"difference :"<<difference <<endl;}
else if(diff_1==1) {cout<<"adjustment necessary"<<endl;}
//executive function
cout<<endl;
cout<<"continue y/n : ";
cin>>j;
if (j!='y')
{
cout<<"terminating program";
flag = false;
}
To copy to clipboard, switch view to plain text mode
Bookmarks