I need help to fix this two errors in the code.
Line: 29 The static method isSolvable() from the type LinearEquation should be accessed in a static way.
Line: 39,40: The static method getX() from the type LinearEquation should be accessed in a static way.
Thank you.
// This is my driver
import java.util.Scanner;
public class LinearEquationTest {
public static void main(String[] args){
Scanner input = new Scanner(System.in); // new a scanner
// input the coefficient
System.out.println("Please input the coefficient a, b, c, d, e,and f: ");
int a = input.nextInt();
int b = input.nextInt();
int c = input.nextInt();
int d = input.nextInt();
int e = input.nextInt();
int f = input.nextInt();
// new a LinearEquation object, and initial with constructor
LinearEquation equations = new LinearEquation(a, b, c, d, e, f);
int userChoice;
boolean exitFlag = false;
while(exitFlag == false){
System.out.println("1.isSolvable() 2.getX() and getY() 3.Exit");
System.out.print("Please choose the method you what to use: ");
userChoice = input.nextInt();
switch(userChoice){
case 1: // use method isSolvable()
if(equations.isSolvable() == 0)
System.out.println("There is no solution in the equations");
else
System.out.println("Yes!! There is a solution in the equations");
break;
case 2: // use methods getX() and getY() to get the solution
if(equations.isSolvable() == 0)
System.out.println("There is no solution QQ");
else
System.out.println("The solution of these equations is x = " + equations.getX()
+ ", y = " + equations.getY() + "!!!");
break;
case 3:
System.out.println("See you next time");
exitFlag = true;
break;
default:
break;
}
}
input.close();
}
}