Você está na página 1de 4

// ConsoleApplication1.

cpp: define el punto de entrada de la aplicacin de consola


.
//
#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <string>
using namespace std;
void CompraProducto()
{
string vendedor1, vendedor2;
string nombre;
int tipoProducto;
string cedula;
int cantidad;
float precioBase = 1500;
float iva = 1.16f;
float percent11 = 0.08f;
float percent12 = 0.95f;
float percent123 = 0.12f;
float percent21 = 0.90f;
float percent31 = 0.85f;
float percent32 = 0.94f;
float percent41 = 0.93f;
float percent42 = 0.87f;
float precioDescuento = 0;
float precioSinDescuento = 0;
float precioFinal = 0;
float ultimoCedula;
int edad;
float percentEdad;

cout << "Ingrese producto a comprar: 1- Elixir; 2- Hechizo de amor; 3- n


irava; 4- sayayin" << endl;
cin >> tipoProducto;
cout << "Ingrese Nombre" << endl;
cin >> nombre;
cout << "Ingrese cedula" << endl;
cin >> cedula;
cout << "Ingrese cantidad a comprar'" << endl;
cin >> cantidad;
cout << "Ingrese ultimo digito cedula'" << endl;
cin >> ultimoCedula;
cout << "Ingrese su edad'" << endl;
cin >> edad;
ultimoCedula = (ultimoCedula / 100) + 1;
percentEdad = (edad / 100) + 1;
//
_asm {
; apilamos los valores para calcular

mov eax, tipoProducto


mov ecx, edad
cmp eax, 1
jne siuno
cmp ecx, 20; si es menor a 20 ingresa
jge siunoedad
FLD precioBase
FLD percent11
FMULP st(1), st
FLD precioBase
FADDP st(1), st
FLD percent12
FMUL ST, ST(1)
FSTP precioDescuento
FSTP precioSinDescuento
jmp siuno
siunoedad :
FLD precioBase
FLD percent123
FMULP st(1), st
FLD precioBase
FADDP st(1), st
FLD percent12
FMUL ST, ST(1)
FSTP precioDescuento
FSTP precioSinDescuento
; vaciamos la pila
jmp finsis
siuno :
cmp eax, 2
jne sidos
cmp ecx, 50; si es mayor a 50 ingresa
jnge sidosedad
FLD precioBase
FLD percent21
FMUL st, st(1)
FSTP precioDescuento
FSTP precioSinDescuento
jmp sidos
sidosedad :
FLD precioBase
FST precioDescuento
FSTP precioSinDescuento
jmp finsis
sidos :
cmp eax, 3
jne sitres
FLD precioBase
FLD ultimoCedula
FMULP st(1), st
mov ecx, cantidad

cmp ecx, 100


jnge sitresuno
cmp ecx, 200
jg sitresdos
FLD percent31
FMUL st, st(1)
FSTP precioDescuento
FSTP precioSinDescuento
jmp sitres
sitresdos :
FLD precioBase
FST precioDescuento
FSTP precioSinDescuento
jmp sitres
sitresuno :
FLD percent32
FMUL st, st(1)
FSTP precioDescuento
FSTP precioSinDescuento
jmp finsis
sitres :
cmp eax, 4
jne finsis
cmp ecx, 30; si no es menor o igual a 30 ingresa
jge sicuatroedad
FLD precioBase
FLD percentEdad;
FMULP st(1), st
jmp sicuatro
sicuatroedad :
FLD precioBase
jmp sicuatro
sicuatro :
mov ecx, cantidad
cmp ecx, 20
jg sicuatrounidad
FLD percent41
FMUL st, st(1)
FSTP precioDescuento
FSTP precioSinDescuento
jmp finsis
sicuatrounidad :
FLD percent42
FMUL st, st(1)
FSTP precioDescuento
FSTP precioSinDescuento
jmp finsis
finsis :
FLD precioDescuento
FLD iva
FMULP st(1), st
FSTP precioFinal
}

cout << "Cliente : '" << nombre << "', con cedula: '" << cedula << "', P
recio: '" << precioBase << "', precio sin descuento:'" << precioSinDescuento <<
"'" << endl;
cout << "precio con Descuento : '" << precioDescuento << "', Precio con
IVA'" << precioFinal << "'" << endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
CompraProducto();
_getch();
return 0;
}

Você também pode gostar