Advertisement
Guest User

p1-2

a guest
Nov 20th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <math.h>
  4. #include <stdlib.h>
  5. #include <ctype.h>
  6.  
  7. int main() {
  8.     int qtd,i;
  9.     char size;
  10.     int quantidade_cap_p;
  11.     int quantidade_cap_g;
  12.     int total;
  13.     int media;
  14.     int total_p = 0;
  15.     int total_g = 0;
  16.  
  17.     i = 0;
  18.     total = 0;
  19.     do
  20.     {
  21.         scanf("%d\n%c", &qtd,&size);
  22.         size = tolower(size);
  23.         switch (size)
  24.         {
  25.         case 'p':
  26.             quantidade_cap_p = qtd * 10;
  27.             total_p = total + quantidade_cap_p;
  28.             total = total_p + total_g;
  29.             break;
  30.  
  31.         case 'g':
  32.             quantidade_cap_g = qtd * 16;
  33.             total_g = total + quantidade_cap_g;
  34.             total = total_p + total_g;
  35.            
  36.             break;
  37.         /*default:
  38.             i++;
  39.             total = total_p + total_g;*/        
  40.         }
  41.         i++;
  42.     }
  43.  
  44.     while (i < 7);
  45.  
  46.    
  47.  
  48.     printf("%d", total);
  49.  
  50.  
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement