I am a newcomer to Java, and in my code attached bellow I have 2 classes, Start.java and ecuație.java. ecuatie.java calculates the square footage of a quadratic ecuation, but for some reason, the constructor doesn't initialize the values properly. Could you shed some light on me as to why does this happen?
package com.ecuatie;
import com.ecuatie.ecuatie;
public class Start {
public static void main(String[] args) {
ecuatie exemplu = new ecuatie(1.0d, 0.0d, -4.0d);
System.out.println(exemplu.delta() + '\n');
System.out.println(exemplu.X1() + '\n');
System.out.println(exemplu.X2() + '\n');
}
}
package com.ecuatie;
import java.lang.Math;
public class ecuatie {
private double a = 0, b = 0, c = 0;
ecuatie(double a, double b, double c) {
this.a = a; this.b = b; this.c = c;
}
public double delta() {
return (b * b) - (4 * a * c);
}
public double X1() {
return (-b + Math.sqrt(delta())) / (2 * a);
}
public double X2() {
return (-b - Math.sqrt(delta())) / (2 * a);
}
}