07-05-2022, 02:05 PM
This is from the QBasic Tech Reference book, and is intended to demonstrate math with complex numbers. I myself can't see through it anymore, but anyone who deals with mathematics can perhaps use it.
Code: (Select All)
'Loesung quadratischer Gleichungen S. 231, QBasic Referenz - 5. Juli 2022
Option _Explicit
Dim a, b, c, det As Double
Dim j As String
Do
Cls
Print "Geben Sie die Parameter a, b, c der Gleichung ax^2 + bx + c = 0 ein: "
Input "a = "; a: Input "b = "; b: Input "c = "; c
Print "Loesung: ";
If a = 0 Then
If b = 0 Then Print "alle Zahlen" Else Print "x = "; -c / b
Else det = b * b - 4 * a * c
If det >= 0 Then
Print "x1 = "; (-b + Sqr(det)) / 2 / a; "x2 = "; (-b - Sqr(det)) / 2 / a
Else
Print "x1 = "; b / 2 / a; "+"; Sqr(det) / 2 / a; "* i;";
Print " x2 = "; b / 2 / a; "-"; Sqr(det) / 2 / a; "* i"
End If
End If
Print
Input "Nochmal (J/N)", j
Loop Until UCase$(j) = "N"
End