Module Module1
Dim b As Double
Dim x1 As Double
Dim a As Double
Dim c As Double
Dim x2 As Double
Dim delta As Double
Sub Main()
Console.WriteLine("===Nhap du lieu===============================================================")
Console.WriteLine()
Console.Write("Nhap vao so A : ")
a = Convert.ToDouble(Console.ReadLine())
Console.Write("Nhap vao so B : ")
b = Convert.ToDouble(Console.ReadLine())
Console.Write("Nhap vao so C : ")
c = Convert.ToDouble(Console.ReadLine())
Console.WriteLine()
delta = b * b - 4 * a * c
Console.WriteLine("===Phuong trinh can giai=======================================================")
Console.WriteLine()
Console.WriteLine()
Console.WriteLine(" 2")
Console.WriteLine("{0}x + {1}x + {2} = 0", a, b, c)
Console.WriteLine()
Console.WriteLine()
If a = 0 Then
Console.WriteLine("Error : Arg Error !")
End If
If delta < 0 Then
Console.WriteLine("===Thong bao=================================================================")
Console.WriteLine("Inf : Phuong trinh vo nghiem !")
ElseIf delta = 0 Then
Console.WriteLine("===Thong bao=================================================================")
Console.WriteLine()
Console.WriteLine("Inf : Phuong trinh co mot nghiem !")
Console.WriteLine()
x1 = -b / a
Console.WriteLine("X1 = {0}", x1)
Else
Console.WriteLine("===Thong bao=================================================================")
Console.WriteLine("Inf : Phuong trinh co 2 nghiem phan biet !")
x1 = ((b - Math.Sqrt(delta)) / (2 * a))
x2 = ((b + Math.Sqrt(delta)) / (2 * a))
Console.WriteLine()
Console.WriteLine()
Console.WriteLine("===Ket qua===================================================================")
Console.WriteLine()
Console.WriteLine("X1 = {0}", x1)
Console.WriteLine("X2 = {0}", x2)
End If
Console.ReadLine()
End Sub
End Module
Không có nhận xét nào:
Đăng nhận xét