Skip to content

Instantly share code, notes, and snippets.

@alvesjnr
Created April 5, 2012 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvesjnr/2311640 to your computer and use it in GitHub Desktop.
Save alvesjnr/2311640 to your computer and use it in GitHub Desktop.
Gosh, NEVER do codes like that!
/*
NOTE: Partially translated from portuguese to english
Menu:
Sandwich Code Price
Hot Dog 100 1,20
Bauru 101 1,30
Bauru with egg 102 1,50
Hamburger 103 1,20
Cheeseburguer 104 1,30
Soda 105 1,00
Write a code which read the sandwich code, the quantity and print the total price
*/
#include <stdio.h>
#include <stdlib.h>
int main()
{
int qtd, n;
float total,cod[105];
cod[5]=0;
qtd=0;
total=0;
n=0;
printf("CHOOSE SANDWICH AND QUANTITY\n");
printf("_________________________________________________\n");
printf("Especificacao\t|\tCodigo\t|\tPreco\t|\n");
printf("Cachorro quente\t|\t100\t|\t1,20\t|\n");
printf("Bauru simples\t|\t101\t|\t1,30\t|\n");
printf("Bauru com ovo\t|\t102\t|\t1,50\t|\n");
printf("Hamburger\t|\t103\t|\t1,20\t|\n");
printf("Cheeseburguer\t|\t104\t|\t1,30\t|\n");
printf("Refrigerante\t|\t105\t|\t1,00\t|\n");
printf("_________________________________________________\n\n");
printf("Informe o codigo: ");
scanf("%d",&n);
cod[n]=n;
if((cod[n]>=100) && (cod[n]<=105))
{
printf("\nInforme a quantidade: ");
scanf("%d",&qtd);
cod[100]=1.20;
cod[101]=1.30;
cod[102]=1.50;
cod[103]=1.20;
cod[104]=1.30;
cod[105]=1.00;
total=(cod[n]*qtd);
printf("\nO total do pedido e: %.2f\n", total);
}
else
{
printf("Voce informou um codigo invalido\n");
}
system("pause");
return 0;
}
@rafaelnovello
Copy link

kkkkkk...que isso?? Trabalho de faculdade??

@alvesjnr
Copy link
Author

alvesjnr commented Apr 5, 2012 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment