-
Lenguaje
Visual Basic .Net
-
Descripción
Solicite 3 números y que permita al usuario seleccionar la operación que desea que realice con los dígitos, entre los cuales se encuentra: 1.- suma, 2.- resta, 3.- multiplicación y 4.- división. Mostrar al usuario el resultado y el tipo de operación realizada.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Module OperacionesCon3Numeros
Sub Main()
Dim operacion As Integer
Dim a, b, resultado As Double
Console.Write("Ingresa el valor de a: ")
a = Double.Parse(Console.ReadLine())
Console.Write("Ingresa el valor de b: ")
b = Double.Parse(Console.ReadLine())
Console.WriteLine("Selecciona el valor de operacion.")
Console.WriteLine(vbTab & "1.- Suma")
Console.WriteLine(vbTab & "2.- Resta")
Console.WriteLine(vbTab & "3.- Multiplicaci" & ChrW(&HF3) & "n")
Console.WriteLine(vbTab & "4.- Divisi" & ChrW(&HF3) & "n")
Console.Write(vbTab & ": ")
Do
operacion = Integer.Parse(Console.ReadLine())
If operacion < 1 Or operacion > 4 Then
Console.Write("Valor incorrecto. Ingrésalo nuevamente.: ")
End If
Loop While operacion < 1 Or operacion > 4
resultado=0
If operacion = 1 Then
Console.WriteLine("Suma")
resultado=a+b
End If
If operacion = 2 Then
Console.WriteLine("Resta")
resultado=a-b
End If
If operacion = 3 Then
Console.WriteLine("Multiplicaci" & ChrW(&HF3) & "n")
resultado=a*b
End If
If operacion = 4 And b <> 0 Then
Console.WriteLine("Divisi" & ChrW(&HF3) & "n")
resultado=a/b
End If
If operacion = 4 And b = 0 Then
Console.WriteLine("Divisi" & ChrW(&HF3) & "n")
Console.WriteLine("Indeterminaci" & ChrW(&HF3) & "n")
End If
Console.WriteLine("Valor de resultado: " & resultado)
Console.WriteLine()
Shell ("cmd /c pause", AppWinStyle.NormalFocus, True)
End Sub
End Module
Sub Main()
Dim operacion As Integer
Dim a, b, resultado As Double
Console.Write("Ingresa el valor de a: ")
a = Double.Parse(Console.ReadLine())
Console.Write("Ingresa el valor de b: ")
b = Double.Parse(Console.ReadLine())
Console.WriteLine("Selecciona el valor de operacion.")
Console.WriteLine(vbTab & "1.- Suma")
Console.WriteLine(vbTab & "2.- Resta")
Console.WriteLine(vbTab & "3.- Multiplicaci" & ChrW(&HF3) & "n")
Console.WriteLine(vbTab & "4.- Divisi" & ChrW(&HF3) & "n")
Console.Write(vbTab & ": ")
Do
operacion = Integer.Parse(Console.ReadLine())
If operacion < 1 Or operacion > 4 Then
Console.Write("Valor incorrecto. Ingrésalo nuevamente.: ")
End If
Loop While operacion < 1 Or operacion > 4
resultado=0
If operacion = 1 Then
Console.WriteLine("Suma")
resultado=a+b
End If
If operacion = 2 Then
Console.WriteLine("Resta")
resultado=a-b
End If
If operacion = 3 Then
Console.WriteLine("Multiplicaci" & ChrW(&HF3) & "n")
resultado=a*b
End If
If operacion = 4 And b <> 0 Then
Console.WriteLine("Divisi" & ChrW(&HF3) & "n")
resultado=a/b
End If
If operacion = 4 And b = 0 Then
Console.WriteLine("Divisi" & ChrW(&HF3) & "n")
Console.WriteLine("Indeterminaci" & ChrW(&HF3) & "n")
End If
Console.WriteLine("Valor de resultado: " & resultado)
Console.WriteLine()
Shell ("cmd /c pause", AppWinStyle.NormalFocus, True)
End Sub
End Module