Advertisement
BearkFear

Exercício sete lista strings UFSM

Nov 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4.  
  5. void recebe (float tipo, char produto[]) {
  6.    
  7.         printf("Digite quantas %s deseja: ", produto);
  8.         int quantidade;
  9.         scanf("%d", &quantidade);
  10.            
  11.         float preco_custo = quantidade * tipo;
  12.         float frete = (5 * preco_custo) / 100;
  13.         preco_custo += frete;
  14.        
  15.         printf("Deseja embalagem para presente: SIM ou NAO: ");
  16.         char embalagem[10];
  17.         while (getchar() != '\n');
  18.         fgets(embalagem, 10, stdin);
  19.        
  20.         printf("\nO preco da venda e de: R$%.2f", preco_custo);
  21.        
  22.    
  23. }
  24.  
  25. int main () {
  26.    
  27.     float rosa, margarida, flores_campo;
  28.    
  29.     printf("Digite o valor dos produtos: \n");
  30.     printf("Rosa: ");
  31.     scanf("%f", &rosa);
  32.     printf("\nMargarida: ");
  33.     scanf("%f", &margarida);
  34.     printf("\nFlores Do Campo: ");
  35.     scanf("%f", &flores_campo);
  36.    
  37.     char produto[20];
  38.    
  39.     int i = 0;
  40.     while (i == 0) {
  41.        
  42.         printf("Digite qual produto deseja: ");
  43.         scanf("%s", produto);
  44.            
  45.         if (strcmp( strlwr(produto), "rosa") == 0 ) {
  46.             recebe(rosa, "rosa");
  47.             i++;
  48.         } else {
  49.                 if (strcmp( strlwr(produto), "margarida") == 0 ) {
  50.                     recebe(margarida, "margarida");
  51.                     i++;
  52.                 } else {
  53.                     if ( strcmp( strlwr(produto), "flores do campo") == 0 ) {
  54.                         recebe(flores_campo, "flores do campo");
  55.                         i++;
  56.                     } else {
  57.                         printf("produto sem estoque!");    
  58.                 }
  59.             }
  60.         }  
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement