Last active
March 20, 2018 00:37
-
-
Save parzibyte/27fc6f7d68ac86aa40aa1f2640c32750 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <ctype.h> | |
/* | |
@author parzibyte | |
@date 19-03-2018 | |
*/ | |
int main(int argc, char const *argv[]) | |
{ | |
float filtroPrecioA = 10, | |
filtroPrecioB = 15, | |
filtroPrecioC = 20, | |
filtroPrecioD = 25, | |
filtroPrecioE = 30; | |
float precioTotal = 0, precioParaElCliente = 0; | |
char eleccionCliente = 0, eleccionFiltro = 0; | |
int numeroDeClientes = 1; | |
//toupper sirve para pasar a mayúscula. Así, no importa si el usuario escribe a o A, etcétera | |
while(eleccionCliente != 'N'){ | |
printf("***************************\n"); | |
printf("* BIENVENIDO, CLIENTE # %d *\n", numeroDeClientes); | |
printf("***************************\n"); | |
while(eleccionFiltro != 'N'){ | |
printf("Elija su filtro\nA B C D E\n[Presione N para terminar esta venta]\n\t\t>"); | |
scanf("%s", &eleccionFiltro); | |
eleccionFiltro = toupper(eleccionFiltro); | |
switch(eleccionFiltro){ | |
case 'A': | |
precioParaElCliente += filtroPrecioA; | |
printf("OK. Ha seleccionado el filtro %c con el precio $%0.2f\n", eleccionFiltro, filtroPrecioA); | |
break; | |
case 'B': | |
precioParaElCliente += filtroPrecioB; | |
printf("OK. Ha seleccionado el filtro %c con el precio $%0.2f\n", eleccionFiltro, filtroPrecioB); | |
break; | |
case 'C': | |
precioParaElCliente += (filtroPrecioC * 0.95); //Hacer el 5 % de descuento | |
printf("OK. Ha seleccionado el filtro %c con el precio $%0.2f\n", eleccionFiltro, filtroPrecioB); | |
printf("Se le hace un descuento del 5 %% ;)\n"); //Doble porcentaje para no formatear cadena | |
break; | |
case 'D': | |
precioParaElCliente += filtroPrecioD; | |
printf("OK. Ha seleccionado el filtro %c con el precio $%0.2f\n", eleccionFiltro, filtroPrecioD); | |
break; | |
case 'E': | |
precioParaElCliente += filtroPrecioE; | |
printf("OK. Ha seleccionado el filtro %c con el precio $%0.2f\n", eleccionFiltro, filtroPrecioE); | |
break; | |
} | |
} | |
printf("Venta terminada. Total: $%0.2f\n", precioParaElCliente); | |
precioTotal += precioParaElCliente; | |
precioParaElCliente = 0; | |
numeroDeClientes++; | |
//Reiniciar elección | |
eleccionFiltro = 0; | |
printf("Desea atender otro cliente? [S/N]\n\t\t>"); | |
scanf("%s", &eleccionCliente); | |
eleccionCliente = toupper(eleccionCliente); | |
} | |
printf("**********************\n"); | |
printf("* CORTE DE CAJA *\n"); | |
printf("**********************\n"); | |
printf("Total vendido: $%0.2f\n", precioTotal); | |
printf("Clientes atendidos: %d\n", numeroDeClientes - 1); //Restar uno | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment