dfi

Páginas: 7 (1543 palabras) Publicado: 18 de noviembre de 2015
Programa que muestre el nombre y los apellidos de una persona

PUBLIC SUB Main ( )

DIM nombre AS String
DIM apelligo AS String
nombre = “manuel”
apellido = “Alvares Gomes”
PRINT apellido & “ , ”& nombre

END

1) Cadena de texto, realizada en consola

PUBLIC SUB Main ( )

DIM Institucion AS String

DIM Pais AS String

DIM Provincia AS String

DIM Canton AS String

Institucion = “UNIDAD EDUCATIVAHUGO CRUZ ANDRADE”

Pais = “Ecuador”

Provincia = “Manabi”

Canton = “El Carmen”

PRINT Institucion
PRINT Canton & “-” & Provincia & “-” & Pais



END

2) Programa en consola para sacar en promedio de 3 notas

PUBLIC SUB Main ( )

DIM NT1 AS Single

DIM NT2 AS Single

DIM NT3 AS Single
DIM suma AS Single

DIM promedio AS Single
PRINT “ingrese la primer nota”
INPUT NT1
PRINT “ingrese la segundanota”
INPUT NT2
PRINT “ingrese la tercer nota”
INPUT NT3

suma = NT1 + NT1 + NT1

Promedio = suma / 3

Provincia = “manuel”

Canton = “Alvares Gomes”

PRINT “ la suma total de las tres notas es:” & suma
PRINT “ el promedios es igual a:” & promedio



END

3) Ejecicio para mostrar la multiplicación división suma y resta de dos numeros

PUBLIC SUB Main ( )

DIM numero1 AS Integer
DIM numero2 ASInteger
DIM suma AS Integer
DIM resta AS Integer
DIM divicion AS Integer
DIM multiplicación AS Integer
numero1 = 30
numero2 = 12
suma = numero1 + numero2
resta = numero1 - numero2
multiplicacion = numero1 * numero2
divicion = numero1 / numero2
PRINT “la suma total de las tres notas es:”&

END




















Select case
Su sintaxi es:
Select[case ] expresión
[case expresión[to expresión #2][,…]
…]
[ case expresión[to expresión #2][,…]
..]
[{case else l default}
…]
End select

Veamos como se aplica al mismo ejemplo anterior de las edades:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
PUBLIC SUB Main ( )

DIM edades AS Integer
...
SELECT CASE edades
CASE 0 TO 2
PRINT “BEBE”
CASE 2 TO 12
PRINT “NIÑO”
CASE 18
PRINT “BINGO YA PUEDES VOTAR”
CASE 13 TO 17
PRINT “JOVEN”
CASE ELSE
PRINT “ADULTO”END

Se trata de un código mucho mas fácil que leer que el anterior.






Ejemplos:
Aplicar un select case para determinar el descuento q se otorga en la próxima compra a un cliente habitual. Y dicho cliente cuenta con tarjeta de crédito de la tienda “RETAIR” y el descuento está relacionado al monto de su factorización del mes de enero se consirera 4 niveles de factorización.
MONTO DE FACTURADOENERO
DESCUENTO DE LA PRÓXIMA COMPRA

>450
>300 y <=450
>150 y <=300
<150

40%
30%
20%
10%

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
PUBLIC SUB Main ( )

DIM DES AS Integer
DIM FAC AS Integer
...
SELECT case DES
CASE 0 TO 150
FAC = 10
CASE 151 TO 300
FAC = 20
CASE 301 TO 450
FAC = 30
CASE > 450
FAC = 40
CASE ELSE
PRINT “PARA LA PROXIMA COMPRA TENDRA UN DESCUENTO DEL: ”
PRINT FAC & ”%”
ENDSELECT








Promediar notas de un x estudiante.
PROMEDIO
9 - 10  DAR
7 - 8.99  AAR
4.01 - 6.99  PARA
< = NAAR

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
PUBLIC SUB Main ( )
DIM A AS Single

PRINT “INGRESE UN VALOR ”
INPUT A
...
SELECT case
Case A > = 9 DO A < = 10
PRINT “DAR ”
ELSE
Case A > = 7 DO A < = 8.99
PRINT “AAR ”
ELSE
Case A < = 6.99
PRINT “PAAR ”
ELSE
Case A < = 4
PRINT“NAAR ”
END SELECT
END












SENTENCIA IF
Su sintaxis es:
if exprexion then

Endif
Ejemplos:
Definir cuál valor es mayor.
A
B
C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
PUBLIC SUB Main ( )

DIM A AS Integer
DIM B AS Integer
DIM C AS Integer
PRINT “INGRESE UN VALOR ”
INPUT A
PRINT “INGRESE OTRO VALOR ”
INPUT B
PRINT “INGRESE UN ULTIMO VALOR ”
INPUT C
...
IF A > B ANDA > C
PRINT “MAYOR ES A ”

IF B > C AND B > A
PRINT “MAYOR ES B ”

ELSE

PRINT “MAYOR ES C ”

ENDIF





Forma de pago:1.2,o 3.
Si es 1 el descuento será 10% del valor.
Si es 2 será 15%.
Si es 3 no habrá descuento.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
PUBLIC SUB Main ( )

DIM A AS Single
DIM FP AS Integer
DIM DES1 AS Single
PRINT “INGRESE UN VALOR ”
INPUT A
PRINT...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Casos de DFI
  • Logistica Dfi
  • Ensayo dfi
  • Cadena de la dfi
  • Formato dfi
  • Cadena dfi
  • Costeo de la dfi
  • DFI GadeG1_Presentacion

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS