this is java Write a class called LinearEquation that does not contain a main()
ID: 653610 • Letter: T
Question
this is java
Write a class called LinearEquation that does not contain a main() method, but it does contains the following:
Six private double fields named a, b, c, d, e, and f.
A six-argument constructor with the arguments for a, b, c, d, e, and f.
Six getter methods for a, b, c, d, e, and f.
A public boolean method named isSolvable() that returns true if ad - bc is not 0, and false otherwise.
Two public double methods named getX() and getY() that return the values of x and y respectively, using the following equations to determine the solutions:
Next, write a test program called TestLinearEquation.java that has a main()method, and that prompts the user to enter values for a, b, c, d, e, and f. Then your program will display the values of x and y, or, if ad - bc equals 0, your program should report that, "The equation has no solution."
Here is a sample input and output:
Explanation / Answer
class LinearEquation
{
double a,b,c,d,e,f;
LinearEquation(a,b,c,d,e,f)
{
{
if((ad-bc)==0)
System.out.println("The equation has no solution");
return false;
else
return true;
}
public double getX()
{
double x=((ed-bf)/(ad-bc));
}
public double getY()
{
double y=((af-ec)/ad-bc));
}
}
public class TestLinearEquation
{
public static void main(String args[])
{
LinearEquation lq(2.0,4.0,5.8,3.6,7.8,9.0);
System.out.println("enter ur choice");
Scanner input = new Scanner(System.in);
if(choice=="yes")
{
System.out.println("enter the values for a,b,c,d,e,f");
double a=in.nextDouble();
double b=in.nextDouble();
double c=in.nextDouble();
double d=in.nextDouble();
double e=in.nextDouble();
double f=in.nextDouble();
lq(a,b,c,d,e,f);
}
else
if(choice=="no")
System.out,println("stop here");
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.