May 2, 2010 at 8:49pm UTC
void breakdown(double change)
{
double q1=0,q2=0,q3=0,q4=0,q5=0,q6=0,q7=0,q8=0,q9=0,q10=0,q11=0,q12=0;
double m1=0,m2=0,m3=0,m4=0,m5=0,m6=0,m7=0,m8=0,m9=0,m10=0,m11=0;
int n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12;
//1000
n1=change/1000;
q1=n1*1000;
m1=change-q1;
cout<<"BREAKDOWN \n";
cout<<"1000-----> "<<n1<<endl;
//500
n2=m1/500;
q2=n2*500;
m2=m1-q2;
cout<<"500------> "<<n2<<endl;
//200
n3=m2/200;
q3=n3*200;
m3=m2-q3;
cout<<"200------> "<<n3<<endl;
//100
n4=m3/100;
q4=n4*100;
m4=m3-q4;
cout<<"100------> "<<n4<<endl;
//50
n5=m4/50;
q5=n5*50;
m5=m4-q5;
cout<<"50------> "<<n5<<endl;
//20
n6=m5/20;
q6=n6*20;
m6=m5-q6;
cout<<"20------> "<<n6<<endl;
//10
n7=m6/10;
q7=n7*10;
m7=m6-q7;
cout<<"10------> "<<n7<<endl;
//1
n8=m7/1;
q8=n8*1;
m8=m7-q8;
cout<<"1------> "<<n8<<endl;
//.5
n9=m8/0.5;
q9=n9*0.5;
m9=m8-q9;
cout<<".5-----> "<<n9<<endl;
//.25
n10=m9/0.25;
q10=n10*0.25;
m10=m9-q10;
cout<<".25-----> "<<n10<<endl;
//.1
if(m10>=.01){
n11=m10/0.1;
q11=n11*0.1;
m11=m10-q11;
cout<<".1-----> "<<n11<<endl;}
//.05
n12=m11/0.05;
q12=n12*0.05;
cout<<".05-----> "<<n12<<endl;
}
May 2, 2010 at 10:32pm UTC
That's an neat piece of code indeed. Not like we're going to do anything with it, but...
-Albatross
Last edited on May 2, 2010 at 10:32pm UTC
May 2, 2010 at 11:07pm UTC
Needs more numbered variables. More repetitive code.
May 2, 2010 at 11:29pm UTC
Okay, so we here in this forum have an absolute ball when someone does something so completely stupid NOT in terms of their code (though, I admit, we will laugh when someone uses 35 numbered variables), but in terms of their post. Since you didn't give us any requests, we will default to gawking.
-Albatross
Last edited on May 2, 2010 at 11:30pm UTC
May 3, 2010 at 12:10am UTC
What exactly is the use for this?