So i was assigned to write a program that would print the answer to the system of two linear equation.

the form of ax+by=c and dx+ey=f

I wrote this program, but it is incorrect since I tried it out on my terminal and I keep getting incorrect values. I would appreciate some help on what I'm doing incorrectly -- my algebra or my programming. Thank You.

import java.util.Scanner;

public class Quest4 {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.print("Enter six numbers: ");

double a = input.nextDouble();

double b = input.nextDouble();

double c = input.nextDouble();

double d = input.nextDouble();

double e = input.nextDouble();

double f = input.nextDouble();

if ((a * d) - (b * c) == 0) {

System.out.println("The equation has no solution");

} else {

double x = (e * d - b * f) / (a * d - b * c);

double y = (a * f - e * c) / (a * d - b * c);

System.out.println(" x is " + x + " and " + " y is " + y);

}

}

}