SHOW:
|
|
- or go back to the newest paste.
1 | #include <cs50.h> | |
2 | #include <math.h> | |
3 | #include <stdio.h> | |
4 | ||
5 | int main (void) | |
6 | { | |
7 | ||
8 | float dollars; | |
9 | int quarters = 0; | |
10 | int dimes = 0; | |
11 | int penny = 0; | |
12 | int nickel = 0; | |
13 | int counter = 0; | |
14 | ||
15 | //a loop to take the user input | |
16 | do | |
17 | { | |
18 | printf("how much change is owed? "); | |
19 | dollars = GetFloat(); | |
20 | ||
21 | } | |
22 | ||
23 | ||
24 | while (dollars <= 0 ); | |
25 | ||
26 | int cent = round(dollars * 100); | |
27 | ||
28 | ||
29 | ||
30 | //loops to collect input and give number of coins left. | |
31 | while (quarters >= 25) | |
32 | { | |
33 | counter++; | |
34 | - | quarters = cent % 25; |
34 | + | |
35 | ||
36 | ||
37 | ||
38 | while(dimes >= 10) | |
39 | counter++; | |
40 | - | dimes = cent % 10; |
40 | + | |
41 | ||
42 | ||
43 | while (nickel >= 5) | |
44 | counter++; | |
45 | - | nickel = cent % 5; |
45 | + | |
46 | ||
47 | ||
48 | ||
49 | //dollars = cent / 5; | |
50 | nickel = cent % 5; | |
51 | while (penny >= 1) | |
52 | counter++; | |
53 | - | penny = cent % 1; |
53 | + | |
54 | ||
55 | ||
56 | - | |
56 | + | |
57 | break; | |
58 | } | |
59 | ||
60 | } |