/**
 * Beschreiben Sie hier die Klasse AB_2_3.
 * 
 * @author (Ihr Name) 
 * @version (eine Versionsnummer oder ein Datum)
 */
public class AB_2_3
{
    /**
     * Berechnet die Nullstelle einer linearen Gleichung y=mx+c
     * und gibt sie auf der Konsole aus
     * 
     * @param m     Steigung
     * @param c     y-Achsenabschnitt
     */
    public static void linear(float m, float c) {
        if (m == 0) {
            if (c == 0) System.out.println("Unendlich viele Nullstellen");
            else System.out.println("keine Nullstelle");
            return;
        }
        float x= - c / m;
        System.out.println("Nullstelle: ("+x+"|0)");
    }
    
    /**
     * berechnet die Nullstellen einer quadratischen Funktion
     * y=ax^2+bx+c und gibt sie auf der Konsole aus.
     * 
     * @param a     quadratischer Koeffizient
     * @param b     linearer Koeffizient
     * @param c     y-Achsenabschnitt
     */
    public static void quadrat(float a, float b, float c) {
        float D = b*b - 4*a*c;
        if (D < 0) System.out.println("keine Nullstellen");
        double x1 = (-b + Math.sqrt(D))/(2*a);
        double x2 = (-b - Math.sqrt(D))/(2*a);
        if (D == 0) System.out.println("eine Nullstellen bei ("+x1+"|0)");
        else System.out.println("Nullstellen bei ("+x1+"|0) und ("+x2+"|0)");
    }
    
    public static int glaeser(int n) {
        int sum = 0;
        for(int i=2; i<=n; i++) {
            sum += i*(i-1)/2;
        }
        return sum;
    }
}