为了账号安全,请及时绑定邮箱和手机立即绑定

Design a class named LinearEquation for a 2×2 system of linear equations: ax + by = e cx + dy = f x = ed−bf ad−bc y = af −ec ad−bc

 Design a class named LinearEquation for a 2×2 system of linear equations: ax + by = e cx + dy = f x = ed−bf ad−bc y = af −ec ad−bc  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 getter methods for a, b, c, d, e, and f • A method named isSolvable() that returns true if ad−bc is not zero. • Methods getX() and getY() that return the solution for the equation. (a). Draw the UML diagram for the class (b) . Implement the class based on the following code.
public class LinearEquation { private double ...; LinearEquation(double a, double b, double c, double d, double e, double f) { ... } double getA() { ... } double getB() { ... } double getC() { ... } double getD() { ... } double getE() { ... } double getF() { ... } boolean isSolvable() { ... } double getX() { ... } double getY() { ... } }
b
(c).Executethe following code and write the output in output.txt
public class TestLE { public static void main(String [] args) { LinearEquation le = new LinearEquation(9.0, 4.0, 3.0, -5.0, -6.0, -21.0); if (le.isSolvable()) System.out.println("x = " + le.getX() + ", y = " + le.getY()); else System.out.println("The equation has no solution"); le = new LinearEquation(1.0, 2.0, 2.0, 4.0, 4.0, 5.0); if (le.isSolvable()) System.out.println("x = " + le.getX() + ", y = " + le.getY()); else System.out.println("The equation has no solution"); } }

正在回答

1 回答

没导入 库?

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

Design a class named LinearEquation for a 2×2 system of linear equations: ax + by = e cx + dy = f x = ed−bf ad−bc y = af −ec ad−bc

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号