Está en la página 1de 3

Ejemplo Estructura secuencial y estructura condicional

doble.
sábado, 4 de marzo de 2023 08:09

1. En un supermercado ofrecen el 10% sobre el total de la compra y un cliente desea saber cuánto
finalmente pagará por su compra. Mostrar en pantalla el nombre del cliente, su número de DUI,
total de la compra y el total a pagar.-

Total de la compra total_compra


Porcentaje de descuento porcent_desc = 0.1
Total a pagar t_pagar
Nombre del cliente nombre_cli
Numero de DUI dui

Entrada Proceso Salida


nombre_cli t_pagar = total_compra - (total_compra * porcent_desc) nombre_cli
dui dui
total_compra total_compra
t_pagar

PSEUDOCÓDIGO.

INICIO
//DEFINICIÓN DE VARIABLES.-
CADENA: nombre_cli, dui ;
REAL: total_compra, t_pagar,

// DEFINICIÓN DE CONSTANTES:
CONSTANTE REAL: porcent_desc = 0.1

// SOLICITUD DE DATOS
Escribir " INGRESE SU NOMBRE: "
Leer: nombre_cli
Escribir "INGRESE SU DUI: "
Leer dui
Escribir "INGRESE EL TOTAL DE LA COMPRA: "
Leer total_compra ;

// PROCESOS
t_pagar = total_compra - (total_compra * porcent_desc) ;

//MOSTRANDO DATOS DE SALIDA

Imprimir: "NOMBRE DEL CLIENTE: ", nombre_cli ;


Imprimir: "NUMERO DE DUI: ", dui ;
Imprimir: "EL TOTAL DE LA COMPRA FUE: ", total_compra ;
Imprimir: "EL TOTAL A PAGAR ES: " , t_pagar ;

FIN

UNIDAD II página 1
FIN

REALIZAR EL SIGUIENTE EJERCICIO CON ESTRUCTURA CONDICIONAL

En un supermercado ofrecen el 10% descuento sobre el total de la compra si esta es menor o igual a
150.00 sino hacer un total del 20% de descuento si la compra es mayor. y un cliente desea saber
cuánto finalmente pagará por su compra. Mostrar en pantalla el nombre del cliente, su número de
DUI, total de la compra y el total a pagar e indicar y qué porcentaje de descuento se le aplicó.-

INICIO

// DEFINICIÓN DE VARIABLES
CADENA: nombre_cli, dui ;
REAL: total_compra, t_pagar , desc ;
CADENA: porcenAplicado ;

// DEFINICIÓN DE CONSTANTES:
CONSTANTE REAL: porcent_desc1 = 0.1 ;
CONSTANTE REAL: porcent_desc2 = 0.2 ;

// SOLICITUD DE DATOS
Escribir " INGRESE SU NOMBRE: "
Leer: nombre_cli
Escribir "INGRESE SU DUI: "
Leer: dui
Escribir "INGRESE EL TOTAL DE LA COMPRA: "
Leer: total_compra ;

// PROCESOS

// HACIENDO USO DE ESTRUCTURAS CONDICIONALES.- EN ESTE CASO ESTRUCTURA


CONDICIÓN DOBLE. DONDE OCUPO UN SINO, EN CASO DE QUE LA CONDICIÓN ME DE FALSA.

190.58 ---> FALSO


Si total_compra <= 150.00 entonces // si esto es verdadero se realiza la instrucción siguiente.

desc = total_compra * porcent_desc1 ;


t_pagar = total_compra - desc ; // REALIZANDO EL DESCUENTO CON EL 10%
porcenAplicado = "10%" ;

SiNo

desc = total_compra * porcent_desc2 ;


t_pagar = total_compra - desc ; // REALIZANDO EL DESCUENTO CON EL 20%
porcenAplicado = "20% ";

FinSi

//MOSTRANDO DATOS DE SALIDA

Imprimir: "NOMBRE DEL CLIENTE: ", nombre_cli ;


Imprimir: "NUMERO DE DUI: ", dui ;
Imprimir: "EL TOTAL DE LA COMPRA FUE: ", total_compra ;

UNIDAD II página 2
//MOSTRANDO DATOS DE SALIDA

Imprimir: "NOMBRE DEL CLIENTE: ", nombre_cli ;


Imprimir: "NUMERO DE DUI: ", dui ;
Imprimir: "EL TOTAL DE LA COMPRA FUE: ", total_compra ;
Imprimir: "EL TOTAL DEL DESCUENTO ES: " , desc ;
Imprimir: "EL PORCENTAJE QUE SE APLICO ES: " , porcenAplicado ;
Imprimir: "EL TOTAL A PAGAR ES: " , t_pagar ;

FIN

UNIDAD II página 3

También podría gustarte