Computer Science, asked by vietnamserver830, 6 months ago

Q. 4 A set of 2 linear equations with 2 unknown values x1 and x2 are given as:
m=ax1+bx2 and n=cx1+x2
The solution of the equations is given as:
x1= md-bn and x2= na-mc
ad-cb
ad-cb
provided the denominator ad-cb is not equal to 0. If it is, print an appropriate
message. Write a program that will accept the values of a,b,c,d,m and n and
compute and display the results of x1 and x2.​

Answers

Answered by Anonymous
5

Answer:

Q. 4 A set of 2 linear equations with 2 unknown values x1 and x2 are given as:

m=ax1+bx2 and n=cx1+x2

The solution of the equations is given as:

x1= md-bn and x2= na-mc

ad-cb

ad-cb

provided the denominator ad-cb is not equal to 0. If it is, print an appropriate

message. Write a program that will accept the values of a,b,c,d,m and n and

compute and display the results of x1 and x2.

Answered by Tulsi4890
0

here's a Python program that implements the solution:

# read in the values of a, b, c, d, m, and n

a = float(input("Enter the value of a: "))

b = float(input("Enter the value of b: "))

c = float(input("Enter the value of c: "))

d = float(input("Enter the value of d: "))

m = float(input("Enter the value of m: "))

n = float(input("Enter the value of n: "))

# compute the denominator

denominator = a*d - b*c

# check if the denominator is zero

if denominator == 0:

print("There is no solution.")

else:

# compute x1 and x2

x1 = (m*d - b*n) / denominator

x2 = (a*n - m*c) / denominator

# display the results

print("x1 = ", x1)

print("x2 = ", x2)

  • The program first prompts the user to enter the values of a, b, c, d, m, and n using the input() function and stores them in variables.
  • The denominator ad-cb is computed and stored in a variable called denominator.
  • The program checks if the denominator is zero using an if statement. If it is, the program prints a message indicating that there is no solution.
  • If the denominator is not zero, the program uses the provided formula to compute x1 and x2 and stores them in variables.
  • Finally, the program displays the results to the user using the print() function.

Note: This program assumes that the input values are valid and can be converted to floating-point numbers. You may want to add error handling to handle cases where the input is not valid.

To learn more about python from the given link.

https://brainly.in/question/22123051

#SPJ3

Similar questions