Advertisement
campos20

Inventario Simples

May 2nd, 2020
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>z
  3.  
  4. // Controle de estoque simples
  5. // Autor: Alexandre Campos
  6.  
  7. int main()
  8. {
  9.     // Declaracao das variaveis
  10.     char item1[100];
  11.     char item2[100];
  12.     char item3[100];
  13.  
  14.     int qtd1;
  15.     int qtd2;
  16.     int qtd3;
  17.  
  18.     double valor1;
  19.     double valor2;
  20.     double valor3;
  21.  
  22.     double total1;
  23.     double total2;
  24.     double total3;
  25.     double total;
  26.  
  27.     // Entrada de dados
  28.     printf("Digite o nome do item 1:\n");
  29.     fgets(item1, 100, stdin);
  30.     printf("Digite o nome do item 2:\n");
  31.     fgets(item2, 100, stdin);
  32.     printf("Digite o nome do item 3:\n");
  33.     fgets(item3, 100, stdin);
  34.  
  35.     printf("Digite a quantidade do item 1:\n");
  36.     scanf("%d", &qtd1);
  37.     printf("Digite a quantidade do item 2:\n");
  38.     scanf("%d", &qtd2);
  39.     printf("Digite a quantidade do item 3:\n");
  40.     scanf("%d", &qtd3);
  41.  
  42.     printf("Digite o valor do item 1:\n");
  43.     scanf("%lf", &valor1);
  44.     printf("Digite o valor do item 2:\n");
  45.     scanf("%lf", &valor2);
  46.     printf("Digite o valor do item 3:\n");
  47.     scanf("%lf", &valor3);
  48.  
  49.     // Logica
  50.     total1 = qtd1 * valor1;
  51.     total2 = qtd2 * valor2;
  52.     total3 = qtd3 * valor3;
  53.  
  54.     total = total1 + total2 + total3;
  55.  
  56.     // Exibicao em tela
  57.     printf("Total do item 1: R$%.2lf\n", total1);
  58.     printf("Total do item 2: R$%.2lf\n", total2);
  59.     printf("Total do item 3: R$%.2lf\n", total3);
  60.     printf("Total: R$%.2lf\n", total);
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement