10 Programas en Visual Studio 2010

Page 1

2do Análisis de Sistemas ESTUDIANTES: sniper guerrero

➢ Braulio Congo ➢ Ligia Narváez


1

Ejercicio 1 –Precio de venta de un producto (IF…Then) .................................... 2 Ejercicio 2 – Áreas y Perímetros de Cuerpos Geométricos................................. 5 Ejemplo 2 – Calculo de Límite de Crédito........................................................... 7 Ejercicio 4 – Calculo de Análisis Combinatorio……………………............................. 9

Ejercicio 5 –Calculo de progresiones aritméticas.............................................. 11 Ejercicio 6 –Calculo de billetes sacados de un cajero........................................ 13 Ejercicio 7 – Promedio de 10 notas de un estudiante....................................... 16 Ejercicio 8 – Valor a pagar de un pedido de comida rápida............................... 18 Ejercicio 9 – Calculo de un rol de pago a un trabajador..................................... 20 Ejercicio 10 –Calculo del precio a pagar de un vehículo ………………………………… 22


2

EJERCICIO 1. _ PRECIO DE VENTA DE UN PRODUCTO

CODIGO Public Class Form1 Dim clave, materia, mano As Double Dim gastof, costop, preciov As Double Dim producto As String Private Sub btncalcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalcular.Click If txtclave.Text = 1 Then producto = "BOTAS MILITARES TALLA 38-41" Label8.Text = producto materia = 10.0 Label9.Text = materia mano = (0.8 * materia) Label10.Text = mano gastof = ((0.28 * materia) + materia) Label11.Text = gastof costop = (materia + mano + gastof) Label12.Text = costop preciov = (costop + (0.45 * costop)) txtpreciov.Text = preciov End If If txtclave.Text = 2 Then producto = "ZAPATO CASUAL COLOR CAFE TALLA 38-41"


3

Label8.Text = producto materia = 10.0 Label9.Text = materia mano = (0.85 * materia) Label10.Text = mano gastof = ((0.3 * materia) + materia) Label11.Text = gastof costop = (materia + mano + gastof) Label12.Text = costop preciov = (costop + (0.45 * costop)) txtpreciov.Text = preciov End If If txtclave.Text = 3 Then producto = "ZAPATO CASUAL COLOR BEIGE TALLA 38-41" Label8.Text = producto materia = 10.0 Label9.Text = materia mano = (0.75 * materia) Label10.Text = mano gastof = ((0.35 * materia) + materia) Label11.Text = gastof costop = (materia + mano + gastof) Label12.Text = costop preciov = (costop + (0.45 * costop)) txtpreciov.Text = preciov End If If txtclave.Text = 4 Then producto = "ZAPATILLA DEPORTIVA COLOR HABANA TALLA 36-40" Label8.Text = producto materia = 10.0 Label9.Text = materia mano = (0.75 * materia) Label10.Text = mano gastof = ((0.28 * materia) + materia) Label11.Text = gastof costop = (materia + mano + gastof) Label12.Text = costop preciov = (costop + (0.45 * costop)) txtpreciov.Text = preciov End If If txtclave.Text = 5 Then producto = "ZAPATILLA DEPORTIVA COLOR NEGRO TALLA 36-40" Label8.Text = producto materia = 10.0 Label9.Text = materia mano = (0.8 * materia) Label10.Text = mano gastof = ((0.3 * materia) + materia) Label11.Text = gastof


4

costop = (materia + mano + gastof) Label12.Text = costop preciov = (costop + (0.45 * costop)) txtpreciov.Text = preciov End If If txtclave.Text = 6 Then producto = "ZAPATILLA DEPORTIVA MONTAÑERA COLOR CAFE TALLA 36-41" Label8.Text = producto materia = 10.0 Label9.Text = materia mano = (0.85 * materia) Label10.Text = mano gastof = ((0.35 * materia) + materia) Label11.Text = gastof costop = (materia + mano + gastof) Label12.Text = costop preciov = (costop + (0.45 * costop)) txtpreciov.Text = preciov End If If txtclave.Text >= 7 Then Label15.Text = "LA CLAVE ES INCORRECTA" End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click txtclave.Text = "" Label8.Text = "" Label9.Text = "" Label10.Text = "" Label11.Text = "" Label12.Text = "" Label15.Text = "" txtpreciov.Text = "" End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click End End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click End End Sub End Class


5

EJERCICIO 2._ CALCULO DE VOLUMENES Y AREAS DE LOS CUERPOS GEOMETRICOS

CODIGO Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dimension As Integer Dim area, volumen As Double dimension = txtdim.Text area = (dimension * dimension) * 6 txtarea.Text = area volumen = dimension * dimension * dimension txtvol.Text = volumen End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim a, b, h As Double Dim area, volumen As Double a = TextBox1.Text


6

b = TextBox2.Text h = TextBox3.Text area = ((2 * a) + (2 * b)) * h + 2 * (a * b) TextBox4.Text = area volumen = (a * b * h) TextBox5.Text = volumen End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim aci, rci As Double Dim area, volumen As Double aci = TextBox6.Text rci = TextBox7.Text area = (2 * 3.1416 * rci) * (aci + rci) TextBox8.Text = area volumen = (3.1416 * (rci * rci) * aci) TextBox9.Text = volumen End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim radio, area, volumen As Double radio = TextBox10.Text area = (4 * 3.1416 * (radio * radio)) TextBox11.Text = area volumen = (1.33 * 3.1416 * (radio * radio * radio)) TextBox12.Text = volumen End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Dim ba, al, areal, volumen As Double ba = TextBox13.Text al = TextBox14.Text areal = ba + al TextBox15.Text = areal volumen = (0.33 * ba) * al TextBox16.Text = volumen End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim rb, al, ap, area, volumen As Double rb = TextBox17.Text ap = TextBox18.Text al = TextBox21.Text area = (3.1416 * rb * ap) + (3.1416 * (rb * rb)) TextBox19.Text = area


7

volumen = 0.33 * (3.1416 * (rb * rb)) * al TextBox20.Text = volumen End Sub End Class

EJERCICIO 3. _LIMITE DE CREDITO

CODIGO Public Class BANCO Private Sub rb1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rb1.CheckedChanged Dim credito, monto As Double If rb1.Checked = True Then monto = txtmonto.Text credito = (monto * 0.25) + monto lblcredito.Text = "SU LIMITE DE CREDITO ES" & " " & credito & " $" End If End Sub Private Sub rb2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rb2.CheckedChanged Dim credito, monto As Double If rb2.Checked = True Then monto = txtmonto.Text


8

credito = (monto * 0.35) + monto lblcredito.Text = "SU LIMITE DE CREDITO ES" & " " & credito & " $" End If End Sub Private Sub rb3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rb3.CheckedChanged Dim credito, monto As Double If rb3.Checked = True Then monto = txtmonto.Text credito = (monto * 0.4) + monto lblcredito.Text = "SU LIMITE DE CREDITO ES" & " " & credito & " $" End If End Sub Private Sub rbotro_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbotro.CheckedChanged Dim credito, monto As Double If rbotro.Checked = True Then monto = txtmonto.Text credito = (monto * 0.5) + monto lblcredito.Text = "SU LIMITE DE CREDITO ES" & " " & credito & " $" End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click txtmonto.Text = "" lblcredito.Text = "" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click End End Sub Private Sub txtmonto_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtmonto.TextChanged End Sub End Class


9

EJERCICIO 4. _CALCULO DE PERMUTACIONES

CODIGO: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim num, pc, i, factorial As Double num = TextBox1.Text pc = (num - 1) Label3.Text = pc pc = CInt(Label3.Text) factorial = 1 For i = 1 To pc factorial = factorial * i Next TextBox2.Text = factorial End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim numv, r, nr, i, factorialn, factorialnr, variacion As Double


10

numv = TextBox3.Text r = TextBox4.Text numv = CInt(TextBox3.Text) factorialn = 1 For i = 1 To numv factorialn = factorialn * i Next Label9.Text = factorialn nr = (numv - r) Label10.Text = nr nr = CInt(Label10.Text) factorialnr = 1 For i = 1 To nr factorialnr = factorialnr * i Next Label11.Text = factorialnr variacion = (factorialn / factorialnr) TextBox5.Text = variacion End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim nc, r, nr, factorialnc, factorialnr, factorialr, combinacion As Double nc = TextBox8.Text r = TextBox9.Text nr = (nc - r) Label20.Text = nr nc = CInt(TextBox8.Text) factorialnc = 1 For i = 1 To nc factorialnc = factorialnc * i Next Label19.Text = factorialnc r = CInt(TextBox9.Text) factorialr = 1 For i = 1 To r factorialr = factorialr * i Next Label22.Text = factorialr nr = CInt(Label20.Text) factorialnr = 1 For i = 1 To nr factorialnr = factorialnr * i Next Label21.Text = factorialnr combinacion = (factorialnc / (factorialr * factorialnr)) TextBox10.Text = combinacion End Sub


11

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim num, i, factorial As Double num = CInt(TextBox6.Text) factorial = 1 For i = 1 To num factorial = factorial * i Next TextBox7.Text = factorial End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click End End Sub End Class

EJERCICIO 5. _CALCULO DE PROGRESIONES ARITMETICAS

CODIGO: Public Class Form1 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim a, n, r, u As Integer


12

a = txta.Text n = txtn.Text r = txtr.Text u = a + (n - 1) * r Label2.Text = u End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim a, n, u, r As Integer a = txta.Text n = txtn.Text u = txtu.Text r = (u - a) / (n - 1) Label27.Text = r End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a, n, u, r As Integer n = txtn.Text u = txtu.Text r = txtr.Text a = u - (n - 1) * r Label32.Text = a End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim a, n, u, r As Integer a = txta.Text u = txtu.Text r = txtr.Text n = (u - a + r) / r Label23.Text = n End Sub Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click Dim a, n, r, s As Integer a = txta.Text n = txtn.Text r = txtr.Text s = n / 2 * (2 * a + (n - 1) * r) Label19.Text = s End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click End End Sub


13

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click txta.Text = "" txtn.Text = "" txtu.Text = "" Label2.Text = "" Label27.Text = "" Label32.Text = "" Label23.Text = "" Label19.Text = "" End Sub End Class

EJERCICIO 6. _ CALCULO DE BILLETES SACADOS DE UN CAJERO


14

CODIGO: Public Class Form1 Dim r, m, b200, b100, b50 As Single Private Sub btnok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnok.Click m = txt1.Text r = m Mod 50 If r = 0 Then b200 = m / 200 m = m Mod 200 b100 = m / 100 m = m Mod 100 b50 = m / 50 m = m Mod 50 txt2.Text = b200 txt3.Text = b100 txt4.Text = b50 MsgBox("Retire su dinero por favor ") Else MsgBox("Monto ingresado es incorrecto ") btncorregir.Focus() End If End Sub Private Sub btnsalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsalir.Click MsgBox("La transaccion ha terminado ") End End Sub Private Sub btncorregir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncorregir.Click txt1.Text = "" txt2.Text = "" txt3.Text = "" txt4.Text = "" End Sub Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click txt1.Text = txt1.Text + "1" End Sub


15

Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click txt1.Text = txt1.Text + "2" End Sub Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click txt1.Text = txt1.Text + "3" End Sub Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click txt1.Text = txt1.Text + "4" End Sub Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click txt1.Text = txt1.Text + "5" End Sub

Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click txt1.Text = txt1.Text + "6" End Sub Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click txt1.Text = txt1.Text + "7" End Sub Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click txt1.Text = txt1.Text + "8" End Sub Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click txt1.Text = txt1.Text + "9" End Sub Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click txt1.Text = txt1.Text + "0" End Sub End Class


16

EJERCICIO 7. _PROMEDIO DE DIEZ NOTAS

CODIGO: Public Class btnpromedio Private Sub btnresul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnresul.Click Dim n1 As Double, n2 As Double, n3 As Double, n4 As Double, n5 As Double, n6 As Double, n7 As Double, n8 As Double, n9 As Double, n10 As Double, resultado As Double n1 = txtn1.Text n2 = txtn2.Text n3 = txtn3.Text n4 = txtn4.Text n5 = txtn5.Text n6 = txtn6.Text n7 = txtn7.Text n8 = txtn8.Text n9 = txtn9.Text n10 = txtn10.Text resultado = (n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10) / 10


17

txtresul.Text = resultado If resultado <= 5 Then txt2.Text = (" Insuficiente ElseIf resultado <= 8 Then txt2.Text = (" Muy buena

")

")

ElseIf resultado <= 10 Then txt2.Text = (" Muy buena

")

End If End Sub Private Sub btnsalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsalir.Click End End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click txtn1.Text = "" txtn2.Text = "" txtn3.Text = "" txtn4.Text = "" txtn5.Text = "" txtn6.Text = "" txtn7.Text = "" txtn8.Text = "" txtn9.Text = "" txtn10.Text = "" txtresul.Text = "" End Sub End Class


18

EJERCICIO 8. _ VALOR A PAGAR DE UN PEDIDO DE COMIDA RĂ PIDA

CODIGO: Public Class Form1 Private Sub rbhambur_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbhambur.CheckedChanged If (rbhambur.Checked) Then txtham.Text = 4.5 txtpapas.Text = 2.2 txtrefresco.Text = 1.5 txtnug.Text = 0 txtpizz.Text = 0 txtensa.Text = 0 txtyogu.Text = 0 txtagua.Text = 0 txtagua.Enabled = False txtensa.Enabled = False txtham.Enabled = False txtnug.Enabled = False txtpapas.Enabled = False


19

txtpizz.Enabled = False txtyogu.Enabled = False txtrefresco.Enabled = False End If End Sub Private Sub rbpizza_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbpizza.CheckedChanged If rbpizza.Checked Then txtham.Text = 0 txtpapas.Text = 0 txtrefresco.Text = 1.5 txtnug.Text = 3.0 txtpizz.Text = 12.0 txtensa.Text = 0 txtyogu.Text = 0 txtagua.Text = 0 txtagua.Enabled = False txtensa.Enabled = False txtham.Enabled = False txtnug.Enabled = False txtpapas.Enabled = False txtpizz.Enabled = False txtensa.Enabled = False txtrefresco.Enabled = False End If End Sub Private Sub rbensalada_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbensalada.CheckedChanged If rbensalada.Checked Then txtham.Text = 0 txtpapas.Text = 0 txtrefresco.Text = 0 txtnug.Text = 0 txtpizz.Text = 0 txtensa.Text = 2.5 txtyogu.Text = 2.25 txtagua.Text = 1.2 txtagua.Enabled = False txtensa.Enabled = False txtham.Enabled = False txtnug.Enabled = False txtpapas.Enabled = False txtpizz.Enabled = False


20

txtyogu.Enabled = False txtrefresco.Enabled = False End If

EJERCICIO 9. _ ROL DE PAGO A UN TRABAJADOR

CODIGO: Public Class Form1 Dim iess, aso, paseo, totaldesc, sueldo As Double Private Sub rbnombrado_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbnombrado.CheckedChanged chkaporte.Checked = True


21

chkaso.Checked = True chkbono.Checked = True iess = (txtsueldo.Text) * 9.35 / 100 aso = (txtsueldo.Text) * 2.15 / 100 paseo = (txtsueldo.Text) * 1.11 / 100 txtiees.Text = iess txtaso.Text = aso txtbono.Text = paseo totaldesc = iess + aso + paseo txtdescuento.Text = totaldesc End Sub Private Sub rbcontatado_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbcontatado.CheckedChanged chkaporte.Checked = True chkaso.Checked = True chkbono.Checked = True iess = txtsueldo.Text * 9.35 / 100 aso = txtsueldo.Text * 1.82 / 100 paseo = txtsueldo.Text * 2.11 / 100 txtiees.Text = iess txtaso.Text = aso txtbono.Text = paseo totaldesc = iess + aso + paseo txtdescuento.Text = totaldesc End Sub Private Sub rbpracticante_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbpracticante.CheckedChanged chkaporte.Checked = True chkaso.Checked = False chkbono.Checked = True iess = txtsueldo.Text * 9.35 / 100 aso = txtsueldo.Text * 1.1 / 100 paseo = txtsueldo.Text * 1.15 / 100 txtiees.Text = iess txtaso.Text = aso txtbono.Text = paseo totaldesc = iess + aso + paseo txtdescuento.Text = totaldesc End Sub Private Sub btncalcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalcular.Click Dim sueldo, pago, desc As Double


22

sueldo = txtsueldo.Text desc = txtdescuento.Text pago = sueldo - desc txtpagar.Text = pago End Sub Private Sub btnnuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnuevo.Click

txt1.Text = "" txt2.Text = "" txtaso.Text = "" txtbono.Text = "" txtdescuento.Text = "" txtiees.Text = "" txtpagar.Text = "" txtsueldo.Text = "" txt1.Focus() End Sub Private Sub btnsalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsalir.Click End End Sub End Class


23

EJERCICIO 10. _ PRECIO A PAGAR DE UN VEHÍCULO

CODIGO: Public Class CAR_MOTOR Private Sub txttexto_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txttexto.TextChanged Dim pa As Double, pv As Double, pt As Double If chkaire.Enabled = True Then pa = pa + 80000 End If If chkalarma.Enabled = True Then pa = pa + 180000 End If If chkexplo.Enabled = True Then pa = pa + 210000 End If


24

If chkrines.Enabled = True Then pa = pa + 210000 End If If chktrans.Enabled = True Then pa = pa + 105000 End If If chkvidrios.Enabled = True Then pa = pa + 100000 End If If rb1994.Enabled = True Then pv = Val(txttexto.Text) - (Val(txttexto.Text) * 0.05) pt = pa + pv txt2.Text = "El precio del vehiculo es de $" & pt & " con un descuento del 5%" Else If rb1999.Enabled = True Then pv = Val(txt2.Text) - (Val(txttexto.Text) * 0.07) pt = pa + pv MsgBox ("El precio del vehiculo es de $" & pt & " con un descuento del 7%" Else If rb2004.Enabled = True Then pv = Val(txt2.Text) - (Val(txttexto.Text) * 0.1) pt = pa + pv MsgBox("El precio del vehiculo es de $" & pt & " con un descuento del 10%")


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.