Introduction to Programming using Python 1st Edition

Published by Pearson
ISBN 10: 0132747189
ISBN 13: 978-0-13274-718-9

Chapter 7 - Objects and Classes - Programming Exercises - Page 238: 7.7

Answer

code

Work Step by Step

# 7.7 (Algebra: linear equations) Design a class named LinearEquation for a # system of linear equations: # The class contains: # ax + by = e cx + dy = f # x =ed - bf / ad - bc # y = af - ec /ad - bc # ■ The private data fields a, b, c, d, e, and f with get methods. # ■ A constructor with the arguments for a, b, c, d, e, and f. # ■ Six get methods for a, b, c, d, e, and f. # ■ A method named isSolvable() that returns true if is not 0. # ■ The methods getX() and getY() that return the solution for the equation. # Draw the UML diagram for the class, and then implement the class. Write a test # program that prompts the user to enter a, b, c, d, e, and f and displays the result. # If ad - bc is 0, report that “The equation has no solution.” from CH7.LinearEquation import LinearEquation a, b, c, d, e, f = eval(input("Enter a,b,c,d,e,f: ")) eq = LinearEquation(a, b, c, d, e, f) if (eq.isSolvable()): print("X:", eq.getX(), "\tY:", eq.getY()) else: print("The equation is not solvable!")
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.