Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4.  
  5. int main()
  6. {
  7.     int total, coin, game, reminder, reminder2;
  8.     char ans;
  9.    
  10.    
  11.     do{
  12.     printf("Enter a coin [10p,20p,50p]: \n");
  13.     scanf("%d", &coin);
  14.    
  15.    
  16.     if(coin!=10 && coin!=20 && coin!=50 && coin!=0){
  17.     printf("invalid coin \n");
  18.    
  19.     }else
  20.    
  21.    
  22.     total=total+coin;
  23.    
  24.    
  25.    
  26.  }while(coin!=0);
  27.    
  28.    
  29.    
  30.     printf("Total is: %d \n", total);
  31.    
  32.    
  33.    
  34.    
  35.     while(total>=50){
  36.     total-=50;
  37.     game+=3;
  38.     }
  39.     while(total>=20){
  40.         game++;
  41.         total-=20;
  42.     }
  43.    
  44.    
  45.    
  46.    
  47.    
  48.     printf("you have: %d games", game);
  49.    
  50.    
  51.    
  52.    
  53.     return 0;
  54.    
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement