![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Registered User Join Date: Sep 2001
Posts: 1
| #include <stdio.h> main () { float change, price, amt_paid; int twenties = 0, tens = 0, fives = 0, ones = 0, quarters = 0, dimes = 0, nickels = 0, pennies = 0; printf("\nPlease enter Price of Item:"); scanf("%f", &price); printf("\nPlease enter Amount Paid:"); scanf("%f", &price); /* Calculations for change*/ change = amt_paid - price; int(change*=100); printf("\nCHANGE = $ "); scanf("%f", &change); while (change>0) { if (change > 20) {++twenties; break ();} else if (change > 10) {++tens; break ();} else if (change > 5) {++fives; break ();} else if (change > 1) {++ones; break ();} else if (change > .25) {++quarters; break ();} else if (change > .10) {++dimes; break ();} else if (change > .05) {++nickels; break ();} else if (change > .01) {++pennies;} } |
| tobyman is offline | |
| | #2 |
| Registered User Join Date: Aug 2001
Posts: 267
| Peeps wonder why I sometimes come down on newbies, its not rying to be unkind... I am simply trying to say, "Think for yourself". Think about it... how much is a quarter worth... 25 cents! A dime... 10 cents! ect. ect. Code: int cents = 0; SPH - Written with a burnt hand. |
| minime6696 is offline | |
| | #3 |
| Registered User Join Date: Aug 2001
Posts: 267
| think about it... its not hard, think, if you REALLY using your whole brain, cannot figure it out, then read the code, but if u CAN than dont read the code I give you. ... Okay if u are readinf this u didnt get it: use simple division. You scan the privce into int cents. then simply devide by the value of the coin... cents / 25; // quarters sometimes I feal as if the school system has truely failed us. no offence to you. SPH |
| minime6696 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|