Design a class named LinearEquation for a 2×2 system of linear equations: ax + by = e cx + dy = f x = ed−bf ad−bc y = af −ec ad−bc
Design a class named LinearEquation for a 2×2 system of linear equations: ax + by = e cx + dy = f x = ed−bf ad−bc y = af −ec ad−bc The class contains:
• Private data fields a, b, c, d, e, and f • A constructor with the arguments for a, b, c, d, e, and f • Six getter methods for a, b, c, d, e, and f • A method named isSolvable() that returns true if ad−bc is not zero. • Methods getX() and getY() that return the solution for the equation. (a). Draw the UML diagram for the class (b) . Implement the class based on the following code.
public class LinearEquation { private double ...; LinearEquation(double a, double b, double c, double d, double e, double f) { ... } double getA() { ... } double getB() { ... } double getC() { ... } double getD() { ... } double getE() { ... } double getF() { ... } boolean isSolvable() { ... } double getX() { ... } double getY() { ... } }
b
(c).Executethe following code and write the output in output.txt
public class TestLE { public static void main(String [] args) { LinearEquation le = new LinearEquation(9.0, 4.0, 3.0, -5.0, -6.0, -21.0); if (le.isSolvable()) System.out.println("x = " + le.getX() + ", y = " + le.getY()); else System.out.println("The equation has no solution"); le = new LinearEquation(1.0, 2.0, 2.0, 4.0, 4.0, 5.0); if (le.isSolvable()) System.out.println("x = " + le.getX() + ", y = " + le.getY()); else System.out.println("The equation has no solution"); } }