uvjek mi izbacuje jedno te isto???
Code:
/** Beispiel quadratische Gleichung */
import java.lang.Math;
public class QGleichung {
public static void main (String[] args) {
double a = Double.parseDouble(args[0]);
double b = Double.parseDouble(args[0]);
double c = Double.parseDouble(args[0]);
double d; // Diskriminante
double re1, im1=0, re2, im2=0; // Real- und Imaginaerteil beider Loesungen
System.out.println("zu loesen a*x*x + b*x + c = 0; a! = 0");
d = b*b - 4*a*c;
if (d >= 0) { // 2 reelle Loesungen
re1 = (-b/(2*a)) + ((Math.sqrt(d)) / (2*a));
re2 = (-b/(2*a)) + ((Math.sqrt(d)) / (2*a));
}
else{ // 2 konjugiert komplexe Loesungen
re1 = -b / (2*a);
im1 = Math.sqrt(-d) / (2*a);
re2 = re1;
im2 = -im1;
}
System.out.println("x1 = " + re1 + " + i*" + im1);
System.out.println("x2 = " + re2 + " + i*" + im2);
}}
/** Beispiel quadratische Gleichung */
import java.lang.Math;
public class QGleichung {
public static void main (String[] args) {
double a = Double.parseDouble(args[0]);
double b = Double.parseDouble(args[0]);
double c = Double.parseDouble(args[0]);
double d; // Diskriminante
double re1, im1=0, re2, im2=0; // Real- und Imaginaerteil beider Loesungen
System.out.println("zu loesen a*x*x + b*x + c = 0; a! = 0");
d = b*b - 4*a*c;
if (d >= 0) { // 2 reelle Loesungen
re1 = (-b/(2*a)) + ((Math.sqrt(d)) / (2*a));
re2 = (-b/(2*a)) + ((Math.sqrt(d)) / (2*a));
}
else{ // 2 konjugiert komplexe Loesungen
re1 = -b / (2*a);
im1 = Math.sqrt(-d) / (2*a);
re2 = re1;
im2 = -im1;
}
System.out.println("x1 = " + re1 + " + i*" + im1);
System.out.println("x2 = " + re2 + " + i*" + im2);
}}