SlideShare una empresa de Scribd logo
1 de 3
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
void clrscr()/*Creando funcion para limpiar pantalla.*/
{
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
COORD coord = {0, 0};
DWORD count;
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(hStdOut, &csbi);
FillConsoleOutputCharacter(hStdOut, ' ', csbi.dwSize.X * csbi.dwSize.Y, coord,
&count);
SetConsoleCursorPosition(hStdOut, coord);
}
void main()
{
int salir,saliryesno;
salir=0;
while(salir==0){
clrscr();/*Llamando la funcion para limpiar pantalla.*/
int random;
float gasto, ncargo;
printf("nINTRODUZCA LA CANTIDAD TOTAL DE LA COMPRA: ");
scanf("%f",&gasto,"n");
while (gasto < 0)
{
printf("NO EXISTEN CARGOS NEGATIVOS INTRODUZCA NUEVO GASTO: ");
scanf("%f",&gasto,"n");
}
if (gasto >= 100)
{
printf("nSU GASTO IGUALA O SUPERA LOS $100.00 Y POR TANTO PARTICIPA EN LA
PROMOCION.n");
printf("ntt COLORtt DESCUENTOnn");
printf("ttBOLA BLANCAtt NO TIENEn");
printf("ttBOLA ROJAtt10 POR CIENTOn");
printf("ttBOLA AZULtt20 POR CIENTOn");
printf("ttBOLA VERDEtt25 POR CIENTOn");
printf("ttBOLA AMARILLAtt50 POR CIENTOnn");
srand(time(NULL));/*Inicializa el generador random*/
random=rand()%5;/*Genera los números random*/
if(random==0){
printf("ALEATORIAMENTE USTED OBTUVO UNA BOLA BLANCAnn");
printf("LO SENTIMOS, NO HA GANADO NINGUN DESCUENTO.");
printf(" EL TOTAL A PAGAR ES DE $%.2fnn",gasto);
}
else{
if(random==1){
printf("ALEATORIAMENTE USTED OBTUVO UNA BOLA ROJAnn");
printf("FELIDADES, HA GANADO UN 10 POR CIENTO DE DESCUENTO nn");
ncargo=gasto-(gasto*0.1);
printf("SU NUEVO TOTAL A PAGAR ES: $%.2fnn", ncargo,"nn");
}
else{
if(random==2){
printf("ALEATORIAMENTE USTED OBTUVO UNA BOLA AZULnn");
printf("FELIDADES, HA GANADO UN 20 POR CIENTO DE DESCUENTO nn");
ncargo=gasto-(gasto*0.2);
printf("SU NUEVO TOTAL A PAGAR ES: $%.2fnn", ncargo,"nn");
}
else{
if(random==3){
printf("ALEATORIAMENTE USTED OBTUVO UNA BOLA VERDEnn");
printf("FELIDADES, HA GANADO UN 25 POR CIENTO DE DESCUENTO nn");
ncargo=gasto-(gasto*0.25);
printf("SU NUEVO TOTAL A PAGAR ES: $%.2fnn", ncargo,"nn");
}
else{
if(random==4){
printf("ALEATORIAMENTE USTED OBTUVO UNA BOLA AMARILLAnn");
printf("FELIDADES, HA GANADO UN 50 POR CIENTO DE DESCUENTO nn");
ncargo=gasto-(gasto*0.5);
printf("SU NUEVO TOTAL A PAGAR ES: $%.2fnn", ncargo,"nn");
}
}
}
}
}
}
else{/*El gasto es menor a $100.00*/
printf("nnLO SENTIMOS, SU GASTO ES MENOR A CIEN DOLARES Y NO APLICA A LA
PROMOCION.nn");
}
printf("SI DESEA SALIR PRESIONE 1 O DE LO CONTRARIO PRESIONE OTRO NUMERO: ");
scanf("%d",&saliryesno);
if(saliryesno==1){
salir=1;
}
}
}

Más contenido relacionado

La actualidad más candente

La actualidad más candente (19)

LENGUAJE ESTANDAR SQL
LENGUAJE ESTANDAR SQLLENGUAJE ESTANDAR SQL
LENGUAJE ESTANDAR SQL
 
Correccion de la prueba mfsi
Correccion de la prueba mfsiCorreccion de la prueba mfsi
Correccion de la prueba mfsi
 
Coloreo
ColoreoColoreo
Coloreo
 
El juego de piedra papel tijera
El juego de piedra papel tijeraEl juego de piedra papel tijera
El juego de piedra papel tijera
 
Andres quintal.doc
Andres quintal.docAndres quintal.doc
Andres quintal.doc
 
Shell
ShellShell
Shell
 
Franklincuñas
Franklincuñas  Franklincuñas
Franklincuñas
 
Programa 14
Programa 14Programa 14
Programa 14
 
Introducción a Processing
Introducción a ProcessingIntroducción a Processing
Introducción a Processing
 
Prueba#3 erika quillupangui
Prueba#3 erika quillupanguiPrueba#3 erika quillupangui
Prueba#3 erika quillupangui
 
JUEGO CONCENTRECE PARA ENTORNO DEV C++
JUEGO CONCENTRECE PARA ENTORNO DEV C++JUEGO CONCENTRECE PARA ENTORNO DEV C++
JUEGO CONCENTRECE PARA ENTORNO DEV C++
 
Cómo hacer una calculadora en java y visual basic
Cómo hacer una calculadora en java y visual basicCómo hacer una calculadora en java y visual basic
Cómo hacer una calculadora en java y visual basic
 
punto de venta
punto de ventapunto de venta
punto de venta
 
Practica
PracticaPractica
Practica
 
Programas
ProgramasProgramas
Programas
 
Ahorcado
AhorcadoAhorcado
Ahorcado
 
CÓDIGO PARA REALIZAR UN CORAZÓN EN LENGUAJE C.
CÓDIGO PARA REALIZAR UN CORAZÓN EN LENGUAJE C.CÓDIGO PARA REALIZAR UN CORAZÓN EN LENGUAJE C.
CÓDIGO PARA REALIZAR UN CORAZÓN EN LENGUAJE C.
 
Colas 1er ejercicio
Colas 1er ejercicioColas 1er ejercicio
Colas 1er ejercicio
 
calculadora en c sharp
calculadora en c sharpcalculadora en c sharp
calculadora en c sharp
 

Similar a Simulador de descuentos aleatorios

Similar a Simulador de descuentos aleatorios (15)

Deber piramide y cubo
Deber piramide y cuboDeber piramide y cubo
Deber piramide y cubo
 
Conalep 1
Conalep 1Conalep 1
Conalep 1
 
Hp
HpHp
Hp
 
Codigo ejemplo j2 me
Codigo ejemplo   j2 meCodigo ejemplo   j2 me
Codigo ejemplo j2 me
 
Acmar trucos de visual basic(2)
Acmar   trucos de visual basic(2)Acmar   trucos de visual basic(2)
Acmar trucos de visual basic(2)
 
Ejemplos c++
Ejemplos c++Ejemplos c++
Ejemplos c++
 
Codigos de programas
Codigos de programasCodigos de programas
Codigos de programas
 
Codigos de programas
Codigos de programasCodigos de programas
Codigos de programas
 
Codigos de programas
Codigos de programasCodigos de programas
Codigos de programas
 
Ejercicios resueltos de borland c++
Ejercicios resueltos de borland c++Ejercicios resueltos de borland c++
Ejercicios resueltos de borland c++
 
Include1
Include1Include1
Include1
 
Include1
Include1Include1
Include1
 
Air plane
Air planeAir plane
Air plane
 
Factura en borland c++
Factura en borland c++Factura en borland c++
Factura en borland c++
 
Trabajo opengl
Trabajo openglTrabajo opengl
Trabajo opengl
 

Más de Karen Eurestii (20)

Diagramas de flujo
Diagramas de flujoDiagramas de flujo
Diagramas de flujo
 
Psudocódigo
PsudocódigoPsudocódigo
Psudocódigo
 
Act.5
Act.5Act.5
Act.5
 
Algortimos
AlgortimosAlgortimos
Algortimos
 
Practica 30
Practica 30Practica 30
Practica 30
 
Practica 29
Practica 29Practica 29
Practica 29
 
Unidad 7
Unidad 7Unidad 7
Unidad 7
 
Practica 28 gaem
Practica 28 gaemPractica 28 gaem
Practica 28 gaem
 
Practica 27
Practica 27Practica 27
Practica 27
 
Practica 26
Practica 26Practica 26
Practica 26
 
Practica 25
Practica 25Practica 25
Practica 25
 
Unidad 6 gaem
Unidad 6 gaemUnidad 6 gaem
Unidad 6 gaem
 
Practica 28 gaem
Practica 28 gaemPractica 28 gaem
Practica 28 gaem
 
Practica 27
Practica 27Practica 27
Practica 27
 
Practica 26
Practica 26Practica 26
Practica 26
 
Practica 26
Practica 26Practica 26
Practica 26
 
Practica 26
Practica 26Practica 26
Practica 26
 
Practica 25
Practica 25Practica 25
Practica 25
 
Unidad 6 gaem
Unidad 6 gaemUnidad 6 gaem
Unidad 6 gaem
 
Practica 30
Practica 30Practica 30
Practica 30
 

Simulador de descuentos aleatorios

  • 1. #include <stdio.h> #include <stdlib.h> #include <time.h> #include <windows.h> void clrscr()/*Creando funcion para limpiar pantalla.*/ { HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); COORD coord = {0, 0}; DWORD count; CONSOLE_SCREEN_BUFFER_INFO csbi; GetConsoleScreenBufferInfo(hStdOut, &csbi); FillConsoleOutputCharacter(hStdOut, ' ', csbi.dwSize.X * csbi.dwSize.Y, coord, &count); SetConsoleCursorPosition(hStdOut, coord); } void main() { int salir,saliryesno; salir=0; while(salir==0){ clrscr();/*Llamando la funcion para limpiar pantalla.*/ int random; float gasto, ncargo; printf("nINTRODUZCA LA CANTIDAD TOTAL DE LA COMPRA: "); scanf("%f",&gasto,"n"); while (gasto < 0) { printf("NO EXISTEN CARGOS NEGATIVOS INTRODUZCA NUEVO GASTO: "); scanf("%f",&gasto,"n"); } if (gasto >= 100) { printf("nSU GASTO IGUALA O SUPERA LOS $100.00 Y POR TANTO PARTICIPA EN LA
  • 2. PROMOCION.n"); printf("ntt COLORtt DESCUENTOnn"); printf("ttBOLA BLANCAtt NO TIENEn"); printf("ttBOLA ROJAtt10 POR CIENTOn"); printf("ttBOLA AZULtt20 POR CIENTOn"); printf("ttBOLA VERDEtt25 POR CIENTOn"); printf("ttBOLA AMARILLAtt50 POR CIENTOnn"); srand(time(NULL));/*Inicializa el generador random*/ random=rand()%5;/*Genera los números random*/ if(random==0){ printf("ALEATORIAMENTE USTED OBTUVO UNA BOLA BLANCAnn"); printf("LO SENTIMOS, NO HA GANADO NINGUN DESCUENTO."); printf(" EL TOTAL A PAGAR ES DE $%.2fnn",gasto); } else{ if(random==1){ printf("ALEATORIAMENTE USTED OBTUVO UNA BOLA ROJAnn"); printf("FELIDADES, HA GANADO UN 10 POR CIENTO DE DESCUENTO nn"); ncargo=gasto-(gasto*0.1); printf("SU NUEVO TOTAL A PAGAR ES: $%.2fnn", ncargo,"nn"); } else{ if(random==2){ printf("ALEATORIAMENTE USTED OBTUVO UNA BOLA AZULnn"); printf("FELIDADES, HA GANADO UN 20 POR CIENTO DE DESCUENTO nn"); ncargo=gasto-(gasto*0.2); printf("SU NUEVO TOTAL A PAGAR ES: $%.2fnn", ncargo,"nn"); } else{ if(random==3){ printf("ALEATORIAMENTE USTED OBTUVO UNA BOLA VERDEnn"); printf("FELIDADES, HA GANADO UN 25 POR CIENTO DE DESCUENTO nn");
  • 3. ncargo=gasto-(gasto*0.25); printf("SU NUEVO TOTAL A PAGAR ES: $%.2fnn", ncargo,"nn"); } else{ if(random==4){ printf("ALEATORIAMENTE USTED OBTUVO UNA BOLA AMARILLAnn"); printf("FELIDADES, HA GANADO UN 50 POR CIENTO DE DESCUENTO nn"); ncargo=gasto-(gasto*0.5); printf("SU NUEVO TOTAL A PAGAR ES: $%.2fnn", ncargo,"nn"); } } } } } } else{/*El gasto es menor a $100.00*/ printf("nnLO SENTIMOS, SU GASTO ES MENOR A CIEN DOLARES Y NO APLICA A LA PROMOCION.nn"); } printf("SI DESEA SALIR PRESIONE 1 O DE LO CONTRARIO PRESIONE OTRO NUMERO: "); scanf("%d",&saliryesno); if(saliryesno==1){ salir=1; } } }