17
PROGRMACION EN GAMBAS PROGRAMA GRAFICOS Y DE CONSOLA BYRON LEONEL LOOR BONE TERCERO “A” SISTEMAS

EJERCICIOS EN GAMBAS

Embed Size (px)

Citation preview

PROGRMACION

EN GAMBAS PROGRAMA GRAFICOS Y DE CONSOLA

BYRON LEONEL LOOR BONE TERCERO “A” SISTEMAS

Primer programa de cadena de texto

Mostrar nombre de la institución Public sub main ( ) Dim Institucion as string Dim Pais as string Dim Provincia as string Dim Canton as string Institucion = “ UNIDAD EDUCATIVA HUGO CRUZ ANDRADE ” Pais = “ECUADOR” Provincia = “MANABI” Canton = “EL CARMEN” Print Institucion Print Canton & “ - ” & Provincia & “-” & Pais End

Programa que calcula el promedio de tres notas Public sub main ( ) Dim N1 as single Dim N2 as single Dim N3 as single Dim S as single Dim P as single Print “ingrese la primer nota” Input N1 Print “ingrese la segunda nota” Input N2 Print “ingrese la tercera nota” Input N3 S = N1 + N2+ N3 P = S / 3 Print “ la suma es : ”, S Print “el promedio es : ”, P End

Public sub main ( ) Dim Nombre as string Dim Apellidos as string Nombre = “ Manuel ” Apellidos = “Alvares Gomez” Print Apellidos & “ , ” & Nombre End

Exportaciones en el ecuador exporta café, cacao y maíz en quintales

se desea calcular el total de portaciones y el porcntaje de cada uno.

Productos exportrados con los siguientes datos: maíz 300, café 400,

cacao 800 Public sub main ( ) Dim Cacao as integer Dim Cafe as integer Dim Maiz as integer Dim P1 as single Dim P2 as single Dim Suma as integer Café = 400 Cacao = 800 Maíz = 300 Suma = Café + Cacao + Maíz P1 = (Café / Suma ) * 100 P2 = (Cacao / Suma ) * 100 P3 = (Maíz / Suma ) * 100 Print “el total de exportaciones es : ” & Suma Print “el procentaje del cafe es : ” & P1 & “ % ” Print “el procentaje del Cacao es : ” & P2 & “ % ” Print “el procentaje del Maíz es : ” & P3 & “ % ” End

Programa que calcula el iva de un producto por consola se debe

mostrar el iva

Public sub main ( ) Dim Valor as single Dim Producto as string Dim Total as single Print “ ingrese el producto ” Input Prodructo Print “ingrese el valor ” Input Valor Total = (Valor * 12 ) / 100 Print “el nombre del producto es : ” & Producto Print “el valor del iva es: ” & Total End

Programa que calcule el área de un triangulo teniendo como datos de

entrada la base y la altura

Public sub main ( ) Dim Base as single Dim Altura as single Dim Area as single Print “ ingrese el altura del triangulo que desea calcular el area ” Input Altura Print “ingrese la base del triangulo que desea calcular la el area ” Input Base Area = (Altura * Base ) / 2 Total = (Valor * 12 ) / 100 Print “el área de triangulo es : ” & Area End

Programa que permita recibir como dato de entrada una distancia

medida en metros y convertirla a kilometros Public sub main ( ) Dim Metro as single Dim Kilometro as single Print “ ingrese la medida en metros para convertirla a kilometros ” Input Metro Kilometro = Metro / 1000 Print “la medida en km es : ” Kilometro End

Programa para resolvamos la siguiente ecuación y = x3 – x2 +2 - 3” Public sub main ( ) Dim x as byte Dim y as single Print “ resolvamos la siguiente ecuación y = x3 – x2 +2 - 3” Print “se le da el valor a x” Input x y = x ^ 3 – x ^ 2 +2 – 3 Print “el resultsdo de la ecuación es : ” & y End

Opresiones básicas de matemáticas Public sub main ( ) Dim B as byte Dim C as byte B = 20 C = 65 Print B +C Print B – C Print B / C Print B * C End

La suma de dos valores Public sub main ( ) Dim A as byte Dim B as byte Dim S as byte A = 20 B = 65 S = A +B Print “la suma es : ” & S End

Programa que permite leer la cantidad y el precio de un producto el

mismo que tiene un descuento de 5% mostrar por pantalla el precio

total Public sub main ( ) Dim Cantidad as single Dim Precio as single Dim Sud as single Dim Des as single Dim Prt as single Dim Producto as string Print “bienvenido a mi programa” Print “ingrese el nombre del producto” Input Producto Print “ingrese la cantidad del producto” Input Cantidad Print “ingrese el precio del producto” Input Precio Sud = Cantidad * Precio Des = Sud * 0.05 Prt = Prt – Des Print “el precio total de producto será ” Print Prt End

Programa que permite ingresar el valor de un producto, y el número

de unidades del mismo, mostrar por pantalla el total de imortaciones,

y tsmbien que muestre la comisión del 15% en consola Public sub main ( ) Dim N_producto as string Dim V_producto as single Dim Unidades as integer Dim Importacion as single Dim Comision as single Dim V_total as single Print “ingrese el nombre de su producto” Input N_producto Print “ingrese el valor por producto” Input V_producto Print “ingrese la unidades de su producto” Input Unidades Importacion = Unidades * V_producto Print “el total de la importaciones” Print “la comisión del 15%” Print Comision V_total = Comision + Importacion Print “el total por el producto la venta es :”Print N_producto & V_total End

Programa que calcula el salario de un trabajador que gana 5 dolares

por hora y trabaja 8 horas diarias Public sub main ( ) Dim Salario as single Dim Horas as single Dim Total as single Salario = 5 Horas = 8 Total = Salario * Horas * Horas Print “el salario semanal del empleado es” Print Total End

En un aula de clase hay 42 alumnos que esta dividido en 30 mujeres y

12 varones calcular el porcentaje

Public sub main ( ) Dim Mujeres as integer Dim Varones as integer Dim Suma as integer Dim P1 as integer Dim P2 as integer Mujeres = 30 Varones = 12 Suma = Mujeres + Varones P1 = Mujeres / Suma * 100 P2 = Varones / Suma * 100 Print “el porcentaje de mujeres y varones es” Print “mujeres :” & P1& “%” Print “Varones:” & P2 & “%” End

Aplicar un select case para determinar el descuento que se otorga en

la próxima compra a un cliente avitual dicho cliente cuenta con

tarjeta d crédito d la tienda RETAIL y el descuento esta relacionado al

monto desu factorización del mas de enero se considera con cuatro

niveles de factorización

Monto facturado ENERO DESCUENTO DE LA PROXIMA COMPRA

>450

300y<=450

>150y<=300

<150

40% 30% 20% 10%

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 & ”%” End select

Promediar Notas De Un X Estudiante.

Promedio

9 - 10 Dar

7 - 8.99 Aar

4.01 - 6.99 Para

< = Naar

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

Definir Cuál Valor Es Mayor.

A B C

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 And A > 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.

Public Sub Main ( ) Dim A As Single Dim Fp As Integer Dim Des1 As Single Print “Ingrese Un Valor ” Input A Print “Ingrese Una Forma De Pago ” Input Fp ... If Fp = 1 Then Des1 = (A * 10 )/100 Print “El Descuento Sera De : ” Des1 Else If Fp = 2 Then Des1 = (A * 15 )/100 Print “El Descuento Sera De : ” Des1 Else Print “No Habra Descuento ” Endif

Definir El Valor De Un Numero: Positivo, Negativo, Neutro Public Sub Main ( ) Dim A As Single Print “Ingrese Un Valor ” Input A ... If A > 0 Print “Positivo ” Else If A < 0 Print “Negativo ” Else If A = 0 Print “Neutro ” Endif

Realiza Un Programa Utilizando La Sentencia For Para Mostrar 10

Veces La Palabra “Amistad”. Public Sub Main ( ) Dim A As Integer For A = 1 To 10 Lisbox.Add(A) Next

Realizar Una Aplicación Que Muestre Los Multiplos De 3 Hasta El 99. Public Sub Main ( ) Dim B As Integer For B = 3 To 99 Step 3 Lisbox.Add(B) Next

Calculadora Basica:

La Codificacion Utilizada Seria:

Public Sub _New() End Public Sub Form_Open() End Public Sub Dial1_Change() End Public Sub Radiobutton1_Click() End Public Sub Listbox1_Click() End Public Sub Label2_Mousedown() End Public Sub Label4_Mousedown() End Public Sub Textbox1_Keypress() End Public Sub Button3_Click() End Public Sub Button4_Click() End Public Sub Btnsuma_Click() Txtresul.Text = Txtprival.Text + Txtsegval.Text End

Public Sub Button1_Click() End Public Sub Btnlimpiar_Click() Txtprival.Txt = “” Txtsegval.Txt = “” Txtresul.Txt = “” End Public Sub Btnsalir_Click() Me.Close End Public Sub Btnresta_Click() Txtresul.Text = Txtprival.Text - Txtsegval.Text End Public Sub Btnmulti_Click() Txtresul.Text = Txtprival.Text * Txtsegval.Text End Public Sub Btndiv_Click() Txtresul.Text = Txtprival.Text / Txtsegval.Text End Public Sub Txtsegval_Keypress() End

Aplicación Para La Edad:

La Codificacion Utilizada Seria:

Public Sub _New() End Public Sub Form_Open() End Public Sub Label4_Mousedown() End Public Sub Label3_Mousedown() End Public Sub Btnejecutar_Click() Dim Edad As Integer Edad = Txtedad.Text If Edad < 2 And Edad > 0 Then Txtresul.Text = “Bebe..” Else If Edad < 12 Then Txtresul.Text = “Niño..” Else If Edad < 18 Then Txtresul.Text = “Adolecente..” Else Txtresul.Text = “Adulto..” Endif

Endif Endif End Public Sub Btnlimpiar_Click() Txtnombre.Text = “” Txtedad.Text = “” Txtresul.Text = “” End Public Sub Btnsalir_Click() Me.Close End

Par O Impar:

La Codificacion Utilizada Seria:

Public Sub _New() End Public Sub Form_Open() End Public Sub Button3_Click() End Public Sub Btnlimp_Click() Txtnumero.Text = “” End Public Sub Btnsalir_Click() Me.Close End Public Sub Btnejecut_Click() Dim Numero As Integer Dim A As Integer Numero = Txtnumero.Text A = Numero Mod 2 If A <= 0 Message(“Par”) Else Message( “Impar”) Endif End