Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Algebra: linear equations) Design a class named LinearEquation for a system of l

ID: 3550569 • Letter: A

Question

Algebra: linear equations) Design a class named LinearEquation for a

system of linear equations:

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 get methods for a, b, c, d, e, and f.

? A method named isSolvable() that returns true if is not 0.

? Methods getX() and getY() that return the solution for the equation.

Draw the UML diagram for the class and then implement the class. Write a test

program that prompts the user to enter a, b, c, d, e, and f and displays the result.

If is 0, report that

(Algebra: 2 times 2 linear equations) Design a class named LinearEquation for a 2 times 2 System of linear equations: 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 get methods for a, b, c, d, e, and f. A method named i sSolvable () that returns true if ad - be is not 0. Methods getX() and getY() that return the solution for the equation. Draw the UML diagram for the class and then implement the class. Write a test program that prompts the user to enter a, b, c, d, e, and f and displays the result. If ad - be is 0, report that "The equation has no solution." See Programming Exercise 3.3 for sample runs.

Explanation / Answer

// Algebra: linear equations) Design a class named LinearEquation for a system of linear equations:
class LinearEquation
{
//The class contains:
// Private data fields a, b, c, d, e, and f.
private int a,b,c,d,e,f;
// A constructor with the arguments for a, b, c, d, e, and f.
public LinearEquation(int a,int b,int c,int d,int e,int f)
{
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.e = e;
this.f = f;
}
// Six get methods for a, b, c, d, e, and f.
public int getA() { return a; }
public int getB() { return b; }
public int getC() { return c; }
public int getD() { return d; }
public int getE() { return e; }
public int getF() { return f; }
// A method named isSolvable() that returns true if is not 0.
public boolean isSolvable()
{
return (a*d-b*c)!=0;
}
//Methods getX() and getY() that return the solution for the equation.
public double getX()
{
return (double)(e*d-b*f)/(double)(a*d-b*c);
}
public double getY()
{
return (double)(a*f-e*c)/(double)(a*d-b*c);
}
}
// Write a test program that prompts the user to enter a, b, c, d, e, and f and displays the result.
//If is 0 report that The equation has no solution. See Programming
public class Tester
{
public static void main(String[] args)
{
LinearEquation L1 = new LinearEquation(1,2,2,1,5,4);
if(L1.isSolvable())
{
System.out.println("Solution is " + L1.getX());
System.out.println("Solution is " + L1.getY());
}
else
System.out.println("The equation has no solution.");
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote