"A arte de programar consiste na arte de organizar e dominar a complexidade."

sexta-feira, 23 de outubro de 2015

Ficha nº5



1.

Código:


Private Sub cmdcalcular_Click()
    If Val(numero.Text) Mod 2 = 0 Then
        resultado.Caption = "Par"
    Else
        resultado.Caption = "Ímpar"
    End If
End Sub

Private Sub cmdsair_Click()
   End
End Sub

2.

Código:


Private Sub cmdcalcular_Click()

    If Val(numero.Text) Mod 3 = 0 And Val(numero.Text) Mod 5 = 0 Then
        resultado.Caption = "O número é múltiplo de ambos"
    Else
        resultado.Caption = "O número não é múltiplo de ambos"
    End If
    
End Sub

Private Sub cmdsair_Click()

    End
    
End Sub

3.

Código:


Private Sub cmdcalcular_Click()
    
    If Val(a.Text) < Val(b.Text) + Val(c.Text) And Val(b.Text) < Val(a.Text) + Val(c.Text) And Val(c.Text) < Val(a.Text) + Val(b.Text) Then
        resultado.Caption = "Podem ser valores de um triângulo"
    Else
        resultado.Caption = "Não podem ser valores de um triângulo"
    End If
End Sub

Private Sub cmdsair_Click()

    End
    
End Sub

4.

Código:

Private Sub cmdcalcular_Click()

    Dim a As Single, b As Single, c As Single
    
    a = Val(Text1.Text)
    b = Val(Text2.Text)
    c = Val(Text3.Text)
    
    If a >= b + c Or b >= a + c Or c >= a + b Then
        resultado.Caption = "Não podem ser valores de um triângulo"
    ElseIf a = b And b = c And a = c Then
        resultado.Caption = "O triângulo é equilátero"
    ElseIf a = b Or a = c Or b = c Then
        resultado.Caption = "O triângulo é isósceles"
    Else
        resultado.Caption = "O triângulos é escaleno"
    End If
    
End Sub

Private Sub cmdsair_Click()

    End
    
End Sub

5.

Código:

Private Sub cmdcalcular_Click()

    Dim a As Long, b As Long, c As Long
    
    a = Val(Text1.Text)
    b = Val(Text2.Text)
    c = Val(Text3.Text)
    
    If a >= b + c Or b >= c + a Or c >= a + b Then
        resultado.Caption = "Não podem ser valores de um triângulos"
    ElseIf a ^ 2 = b ^ 2 + c ^ 2 Then
        resultado.Caption = "É um triângulo rectângulo"
    ElseIf a ^ 2 > b ^ 2 + c ^ 2 Then
        resultado.Caption = "É triângulo obtusângulo"
    ElseIf a ^ 2 < b ^ 2 + c ^ 2 Then
        resultado.Caption = "É um triângulo acutângulo"
    End If
    
End Sub

Private Sub cmdsair_Click()

    End
    
End Sub


Sem comentários:

Enviar um comentário