Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There is two parts, an exe Linear Equation and the code itself, both below. Linear Equation: package edu.wit.cs.comp1050; //TODO: document this class public class LinearEquation

There is two parts, an exe "Linear Equation" and the code itself, both below.

image text in transcribed

Linear Equation:

package edu.wit.cs.comp1050;

//TODO: document this class public class LinearEquation { /** * Initialize the linear equation of form: * ax + by = e * cx + dy = f * * @param a parameter a * @param b parameter b * @param c parameter c * @param d parameter d * @param e parameter e * @param f parameter f */ public LinearEquation(double a, double b, double c, double d, double e, double f) { // replace with your code } /** * Convenience constructor to initialize * the linear equation via array * * THIS CONSTRUCTOR CALLS THE CONSTRUCTOR * ABOVE USING THE ARRAY CONTENTS * * @param p parameter array, assumed to be length 6 (a-f, in order) */ public LinearEquation(double[] p) { // MUST call the above constructor // with the contents of p } /** * Returns parameter a * * @return a */ public double getA() { return 0.; // replace with your code } /** * Returns parameter b * * @return b */ public double getB() { return 0.; // replace with your code } /** * Returns parameter c * * @return c */ public double getC() { return 0.; // replace with your code } /** * Returns parameter d * * @return d */ public double getD() { return 0.; // replace with your code } /** * Returns parameter e * * @return e */ public double getE() { return 0.; // replace with your code } /** * Returns parameter f * * @return f */ public double getF() { return 0.; // replace with your code } /** * Returns true if the parameterized * equation is solvable (i.e. denominator * ad-bc is not 0) * * @return true if solvable, false otherwise */ public boolean isSolvable() { return false; // replace with your code } /** * Returns solution for x if solvable, * null otherwise * * @return x if solvable, null otherwise */ public Double getX() { return null; // replace with your code } /** * Returns solution for y if solvable, * null otherwise * * @return y if solvable, null otherwise */ public Double getY() { return null; // replace with your code }

}

Code:

package edu.wit.cs.comp1050;

//TODO: document this class public class PA3b { /** * 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 }

}

Problem b (PA3b.java) You are to first implement a class named LinearEquation for a 2x2 set of linear equations ax + by e ed - bf adbo af - ec adb The class has two constructors to provide the equation parameters (a-f), six getter methods for these parameters, a methodd to determine parameters, a method to determine if the linear system is solvable (i.e. whether the denominator of the x/y equations equals o), and methods to get x/y (or null, if the system isn't 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... $ java edu.wit.cs.comp1050 . PA3 Please supply 6 numbers (a-f) $ java edu.wit.cs.comp1050.PA3b 1.0 2.0 2.0 4.0 4.0 5.e The equation has no solution $. Java edu . wit .cs.comp1050. PA3b Solution : x-2.000, y:3.000 9.0 4.0 3.0-5.0-6.0-21.0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions