Question
You are to first implement a class named LinearEquation for a 2x2 set of linear equations: ax+by=e cx+dy=f x= ed-bf ad-bc y= af-ec ad-bc The
You are to first implement a class named LinearEquation for a 2x2 set of linear equations:
ax+by=e
cx+dy=f
x=ed-bfad-bc
y=af-ecad-bc
The class has two constructors to provide the equation parameters (a-f), six getter methods for these parameters, a method to determine if the linear system is solvable (i.e. whether the denominator of the x/y equations equals 0), and methods to get x/y (or null, if the system isnt solvable).
You must also write a program that takes the parameters (a-f) via command-line arguments, validates the input, and outputs either an error (due to invalid inputs or a non-solvable system) or the solution (with three decimal places of precision). For example, consider the following runs
Please supply 6 numbers (a-f).
The equation has no solution.
Solution: x=-2.000, y=3.000
package comp2010;
//TODO: document this class public class Lab { /** * Error to display if the command-line arguments are invalid */ public static final String ERR_USAGE = "Please supply 6 numbers (a-f)."; /** * Error to display if the equation has no solution */ public static final String ERR_NOSLTN = "The equation has no solution."; /** * Number of required parameters (a-f) */ public static final int NUM_PARAMS = 6; /** * Validates command-line arguments and returns * parameters if valid * * @param args command-line arguments * @return if valid an array of parameters, else null */ public static double[] validateArgs(String[] args) { return null; // replace with your code }
/** * Uses command-line arguments to create * an instance of the linear equation, * and reports the outcome * * @param args command-line arguments, interpreted as equation parameters */ public static void main(String[] args) { // replace with your code }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started