Está en la página 1de 6

UNIVERSIDAD POLITCNICA

SALESIANA

INGENIERA MECNICA

Programacin

Visual Basic

KEVIN SUQUILLO

MECNICA 2 GRUPO 2
Realizar un programa que lea las coordenadas de los vrtices un tringulo
rectngulo y calcule hipotenusa, permetro, rea. Para el caso del
programa en visual basic dibujar la figura en el formulario.

Cdigo:

Proceso Tringulo_Rectngulo

definir ar, per, hip, b, h Como Real

Escribir "Medidas del tringulo rectngulo:"

Escribir "Ingrese la medidad de la base"

leer b

Escribir "Ingrese la medida de la altura"

Leer h

ar<-(b*h)/2

Escribir "El rea del tringulo es: ", ar

hip<-rc [(h^2)+(b^2)]

Escribir "La hipotenusa del tringulo es: ", hip

per<-b+h+hip

Escribir "El permetro del tringulo es: ", per

FinProceso
Demostracin:

Visual studio.

Cdigo:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim x1, y1 As Integer
Dim x2, y2 As Integer
Dim x3, y3 As Integer
Dim a As Integer = 30

If (txt_x1.Text = "" And txt_x2.Text = "" And txt_x3.Text = "" And txt_y1.Text
= "" And txt_y2.Text = "" And txt_y3.Text = "") Then
MsgBox("Ingrese los valores")
Else
x1 = txt_x1.Text
x2 = txt_x2.Text
x3 = txt_x3.Text

y1 = txt_y1.Text
y2 = txt_y2.Text
y3 = txt_y3.Text
Dim p1 As Point
Dim p2 As Point
Dim p3 As Point
p1.X = x1
p1.Y = y1

p2.X = x2
p2.Y = y2
p3.X = x3
p3.Y = y3

Dim d1 As Double = Math.Sqrt(((x2 - x1) ^ 2 + (y2 - y1) ^ 2))


Dim d2 As Double = Math.Sqrt(((x3 - x1) ^ 2 + (y3 - y1) ^ 2))
Dim d3 As Double = Math.Sqrt(((x2 - x3) ^ 2 + (y2 - y3) ^ 2))
Dim hip As Integer
Dim area As Double
Dim triangle As Point() = {p1, p2, p3}
Me.CreateGraphics.DrawPolygon(Pens.Black, triangle)

If (d1 > d2 And d1 > d3) Then


hip = d1
area = CDbl((d2 * d3) / 2)
ElseIf (d2 > d1 And d2 > d3) Then
hip = d2
area = CDbl((d1 * d3) / 2)
ElseIf (d3 > d1 And d3 > d2) Then
hip = d3
area = CDbl((d1 * d2) / 2)
End If

txt_area.Text = area
txt_perimetro.Text = d1 + d2 + d3
txt_hip.Text = hip

End If

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
txt_area.ReadOnly = True
txt_hip.ReadOnly = True
txt_perimetro.ReadOnly = True
End Sub
End Class
Demostracin:

Realizar un programa que lea las coordenadas de los vrtices un


rectngulo y calcule permetro, rea. Para el caso del programa en visual
basic dibujar la figura en el formulario.

Cdigo:

Algoritmo Rectangulo

definir b, h, per, ar Como real

Escribir "Ingrese la medida de la base"

Leer b

Escribir "Ingrese la medida de altura"

Leer h

per<-2*b + 2*h

Escribir "El rea del rectangulo es:", per

ar<-b*h
Escribir "El rea del rectangulo es:", ar

FinAlgoritmo

Demostracin:

También podría gustarte