# Solving simultaneous equations

### Question

• How do I go about solving simple two unknown's simultaneous equations? I.e. X + Y = 3 and 2X + 3Y = 8, find the values of X and Y (it is Y = 2 and X = 1). I'm having trouble working out how exactly to do this as when the equation is input it is as one variable and hence I'm not sure how to solve it. the general equation is aX + bY + C = 0 so perhaps thsi may be used in some way although I'm unsure.

Wednesday, November 19, 2008 2:46 AM

• Here's one approach:

 TextWindow.WriteLine("First Equation (ax + by = c)") TextWindow.Write("a: ") a1 = TextWindow.ReadNumber() TextWindow.Write("b: ") b1 = TextWindow.ReadNumber() TextWindow.Write("c: ") c1 = TextWindow.ReadNumber() TextWindow.WriteLine("") TextWindow.WriteLine("Second Equation (ax + by = c)") TextWindow.Write("a: ") a2 = TextWindow.ReadNumber() TextWindow.Write("b: ") b2 = TextWindow.ReadNumber() TextWindow.Write("c: ") c2 = TextWindow.ReadNumber() TextWindow.WriteLine("") num = c2 * a1 - a2 * c1 den = a1 * b2 - a2 * b1 y = num / den x = (c1 - b1 * y) / a1 TextWindow.WriteLine("x: " + x) TextWindow.WriteLine("y: " + y)
Thursday, November 20, 2008 7:13 AM

### All replies

• Here's one approach:

 TextWindow.WriteLine("First Equation (ax + by = c)") TextWindow.Write("a: ") a1 = TextWindow.ReadNumber() TextWindow.Write("b: ") b1 = TextWindow.ReadNumber() TextWindow.Write("c: ") c1 = TextWindow.ReadNumber() TextWindow.WriteLine("") TextWindow.WriteLine("Second Equation (ax + by = c)") TextWindow.Write("a: ") a2 = TextWindow.ReadNumber() TextWindow.Write("b: ") b2 = TextWindow.ReadNumber() TextWindow.Write("c: ") c2 = TextWindow.ReadNumber() TextWindow.WriteLine("") num = c2 * a1 - a2 * c1 den = a1 * b2 - a2 * b1 y = num / den x = (c1 - b1 * y) / a1 TextWindow.WriteLine("x: " + x) TextWindow.WriteLine("y: " + y)
Thursday, November 20, 2008 7:13 AM
• Thanks for the help Vijjaye.
Thursday, November 20, 2008 1:52 PM