View difference between Paste ID: 33Gn208a and 5CdeJviF
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 cent = 0;
9+
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-
        dollars = GetFloat(); 
20+
21-
           //changing float to int
21+
22-
            int (dollars); 
22+
23-
          dollars = dollars * 100;
23+
24-
          cent = round(dollars);    
24+
           //changing from float to int.
25
     int  cent = round(dollars * 100); 
26
   
27
   
28
      //loops to collect input and give number of coins left.
29
     while (dollars >= 25)
30
          counter ++;
31-
     /**changing dollar to cents
31+
32-
        float roundf(float dollars);
32+
33-
        dollars = (dollars * 100);    
33+
34-
        cent = dollars; */
34+
35
             counter++;
36-
        //  cent = round(dollars * 100); 
36+
37
          dollars = dollars % 10;
38
       while (dollars >= 5)
39
             counter++;
40
             nickel--;
41
             dollars = dollars / 5;
42
           dollars = dollars % 5;
43
      while (dollars >= 1)
44
             counter++;
45
             penny --;
46
         dollars = dollars / 1;
47
        dollars = dollars % 1;
48
        
49
   printf("i have %d coins ", counter);
50
         
51
}