Pedido da Lanchonete
Autor: Ben-hur Ott | Publicado: 2011-06-01T21:48:00-07:00





#include&lt;stdio.h&gt;
#include&lt;stdlib.h&gt;


int main(){


&nbsp; &nbsp; system("color 0b");


&nbsp; &nbsp; int codigo=0, quant=0, piz=0, pas=0, bol=0, ref=0, caf=0;
&nbsp; &nbsp; float valor=0, total=0;


&nbsp; &nbsp; printf("Codigo &nbsp; &nbsp; Produto &nbsp; &nbsp; Valor\n");
&nbsp; &nbsp; printf("100 &nbsp; &nbsp; &nbsp; &nbsp; Pizza &nbsp; &nbsp; &nbsp; 2.00\n");
&nbsp; &nbsp; printf("101 &nbsp; &nbsp; &nbsp; &nbsp; Pastel &nbsp; &nbsp; &nbsp;1.50\n");
&nbsp; &nbsp; printf("102 &nbsp; &nbsp; &nbsp; &nbsp; Bolo &nbsp; &nbsp; &nbsp; &nbsp;2.00\n");
&nbsp; &nbsp; printf("103 &nbsp; &nbsp; &nbsp; &nbsp; Refri &nbsp; &nbsp; &nbsp; 1.00\n");
&nbsp; &nbsp; printf("104 &nbsp; &nbsp; &nbsp; &nbsp; Cafe &nbsp; &nbsp; &nbsp; &nbsp;0.80\n");
&nbsp; &nbsp; printf("105------------Fechar Pedido\n");


do{
&nbsp; &nbsp; printf("\nDigite o codigo: ");
&nbsp; &nbsp; scanf("%d",&amp;codigo);
&nbsp; &nbsp; &nbsp; &nbsp; while(codigo&lt;100 || codigo&gt;105){
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf("\nErro, digite o codigo novamente: ");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf("%d",&amp;codigo);
&nbsp; &nbsp; &nbsp; &nbsp; }


&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(codigo==100){ printf("***Pizza***");}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(codigo==101){ printf("***Pastel***");}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(codigo==102){ printf("***Bolo***");}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(codigo==103){ printf("***Refri***");}
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(codigo==104){ printf("***Cafe***");}




if(codigo!=105){
&nbsp; &nbsp; printf("\nDigite a quantidade: ");
&nbsp; &nbsp; scanf("%d",&amp;quant);
&nbsp; &nbsp; &nbsp; &nbsp; while(quant&lt;0){
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printf("\nErro, digite a quantidade novamente: ");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scanf("%d",&amp;quant);
&nbsp; &nbsp; &nbsp; &nbsp; }
}




&nbsp; &nbsp; if(codigo==100){ //PIZZA
&nbsp; &nbsp; &nbsp; &nbsp; valor=valor+(2*quant);
&nbsp; &nbsp; &nbsp; &nbsp; piz=piz+quant;
&nbsp; &nbsp; }


&nbsp; &nbsp; if(codigo==101){ //PASTEL
&nbsp; &nbsp; &nbsp; &nbsp; valor=valor+(1.5*quant);
&nbsp; &nbsp; &nbsp; &nbsp; pas=pas+quant;
&nbsp; &nbsp; }


&nbsp; &nbsp; if(codigo==102){ //BOLO
&nbsp; &nbsp; &nbsp; &nbsp; valor=valor+(2*quant);
&nbsp; &nbsp; &nbsp; &nbsp; bol=bol+quant;
&nbsp; &nbsp; }


&nbsp; &nbsp; if(codigo==103){ //REFRI
&nbsp; &nbsp; &nbsp; &nbsp; valor=valor+(1*quant);
&nbsp; &nbsp; &nbsp; &nbsp; ref=ref+quant;
&nbsp; &nbsp; }


&nbsp; &nbsp; if(codigo==104){ //CAFE
&nbsp; &nbsp; &nbsp; &nbsp; valor=valor+(0.8*quant);
&nbsp; &nbsp; &nbsp; &nbsp; caf=caf+quant;
&nbsp; &nbsp; }


}while(codigo!=105);


printf("\n#================================#\n");
printf("| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;%d Pizza(s) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|\n",piz);
printf("| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;%d Pastel(is) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|\n",pas);
printf("| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;%d Bolo(s) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |\n",bol);
printf("| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;%d Refri(s) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|\n",ref);
printf("| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;%d Cafe(s) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |\n",caf);
printf("#================================#\n\n");




printf("Total do pedido: R$%.2f\n\n",valor);
system("pause");
}