Hey everyone,
I am having difficulty parsing digits in java. By that I mean that I am trying to make a program print out the number of bills the user recieves when he/she recieves change after there payment, (Cash register).
Here is the code i've created to do this for me, it runs perfectly but it always ends up giving out the wrong amount of change.
double change = payment - totalcost ;
double hundredbills = change/100;
change = change%100;
double fiftybills = change/50;
change = change%50;
double twentybills = change/20;
change = change%20;
double tenbills = change/10;
change = change%10;
double fivebills = change/5;
change = change%5;
double toonie = change/2;
change = change%2;
double loonie = change/1;
change = change%1;
double quarter = change/0.25;
change = change%0.25;
double dime = change/0.10;
change = change%0.10;
double nickel = change/0.05;
change = change%0.05;
double penny = change/0.01;
Each of these variables are then printed out with the system.out.println command.