Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cs50.h>
  3.  
  4. float f;
  5.  
  6. int main(void){
  7.     printf("Hi! How much change is owed?\n");
  8.     f = get_float();
  9.    
  10.     while(f < 0){
  11.         printf("Give me a positive number, bro!\n");
  12.         f = get_float();
  13.     }
  14.    
  15.     if(f == 0){
  16.         printf("\nSo what the hell are you waiting for?\n");
  17.         return 0;
  18.     }
  19.    
  20.     int change = f * 100;
  21.  
  22.     int amount = change / 25;
  23.     change %= 25;
  24.  
  25.     amount += change / 10;
  26.     change %= 10;
  27.  
  28.     amount += change / 5;
  29.     change %= rating;
  30.  
  31.     amount += change;
  32.    
  33.     printf("\n%i\n", amount);
  34.     printf("Have a nice day!\n");
  35.    
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement