Risolvere un’equazione di primo grado ax+b=0, dati i valori dei coefficienti a e b.
Un po’ di matematica…

Esempi
| Istanza | Elaborazione | Risposta | ||
| 1 | x+2=0 |
|
|
-2 |
|---|---|---|---|---|
| 2 | 2x-3=0 |
|
|
3/2 |
| 3 | 0x+0=0 |
|
|
Indeterminata |
| 4 | 0x+2=0 |
|
|
Impossibile |
TextWindow.WriteLine("EQUAZIONE DI PRIMO GRADO: Ax+B=0")
TextWindow.WriteLine("--------------------------------------------")
TextWindow.Write("A = ")
a=TextWindow.ReadNumber()
TextWindow.Write("B = ")
b=TextWindow.ReadNumber()
TextWindow.WriteLine("--------------------------------------------")
If(a <> 0) Then
x=-b/a
TextWindow.WriteLine("X = " + x)
Else
If(b = 0) then
TextWindow.WriteLine("INDETERMINATA")
Else
TextWindow.WriteLine("IMPOSSIBILE")
EndIf
EndIf
TextWindow.WriteLine("--------------------------------------------")