473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

2 equations 2 unknown Calculator

I am trying to make a windows app where i can write to equations, in 2 textboxes, with 2 unknown, x and y, and then press a button and get the x and y written in a label or something.
I have tried to make it myself and i have used about 10 hours the last 2 days so now i have to just ask for help.

The app hould calculate x and y by this formel(on danish it is called "determinant-metoden" and i would translate it to be "determinant-method", but i haven't found anything about how to say it on englsih):

D= a1*b2-a2*b1 (if D == 0 then it should not continue with the following because then there is no answer or there is infinite anwsers)

Dx = c1*b2-c2*b1
Dy = a1*c2-a2*c1

x = Dx/D
y = Dy/D

Just ask if you have any questions. =)
Sep 3 '09 #1
10 5835
cloud255
427 Expert 256MB
So what problem are you experiencing exactly?
Sep 3 '09 #2
I don't know how i can define a, b and c in a user written text.. I tried to use Split but then the equation have to be written in a certain way each time and i can't use that to anythins.. =s
But i know that "a" have to be the number before "x", and "b" have to be the number before "y" and "c" is the number before or after "=".
Sep 3 '09 #3
cloud255
427 Expert 256MB
You need to create user inputs like text boxes or numeric up down controls, you then save this value to a variable and perform the equation using that variable:

Expand|Select|Wrap|Line Numbers
  1. int a = (int) Textbox1.Text;
  2. int b = (int) txtMyBValue.Text;
  3. //etc
  4.  
  5. if(D == 0)
  6.    return;
  7.  
  8. int Dx = c1*b2-c2*b1;
  9. //etc
  10.  
  11. float x = Dx/D;
  12.  
  13.  
  14.  

Or have I misunderstood the problem you are facing?
Sep 3 '09 #4
I think you have misunderstood.
I need a textbox to each variable the way you do it(if i understood it right) and that is possible cause i have made one of them but isn't it possible to make something like this with only two textbox?

Sep 3 '09 #5
GaryTexmo
1,501 Expert 1GB
Are you basically looking to create an equation solver that will take any two arbitrary equations and solve them?
Sep 3 '09 #6
Yeah any 2 equations with 2 unkown
Sep 3 '09 #7
GaryTexmo
1,501 Expert 1GB
That's definitely not going to be an easy task for you.

I'd start by building an equation parser/solver with numbers, not variables. I made one once, about 3 years ago but it was in a programming language called Haskell and I can't remember many details anyway. Basically, you'll want to break things up into a set of operations based on what you parse out. Don't forget to do bracket matching either!

Anyway, once you have a solver working with numbers, you can start implementing variables to get your equations in. At that point you'll need to need to start thinking about how to solve any given set of equations based what you have. So like, eliminating common variables between the equations, getting common denominators, etc...

As I said, not an easy task by any stretch! If I can find the code for my Haskell numeric equation solver, I'll post it later. I don't think it was very long, but that's the beauty of a functional programming language. Hopefully it gives you something to go on.

I might as well mention that if you do a bit of googling, you might find something someone else has already written, so that might give you a bit of a leg up on the task.

Good luck!
Sep 3 '09 #8
GaryTexmo
1,501 Expert 1GB
Here, this should help...

http://www.osix.net/modules/article/?id=776
Sep 3 '09 #9
Okay.. I have looked at it but its too complicated for me now, i just thought there was a more simple way to do it. But thank you very much for your help and time. I will still fight to get it done but i am quite sure it will be hard. =)
Sep 3 '09 #10
cloud255
427 Expert 256MB
What you want to build is fairly complex and bordering on a functional programming language... You need to consider things like trigonometry, abstract math rules vs standard algebra, etc. this is really a huge area of study. I find it rather interesting (although the math is often above me).

A far smarter man than I has come up with a language which might interest you: Jos's new functional language
Sep 4 '09 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: smjmitchell | last post by:
Hi All, I need to display some equations on a form in VB (I will print the result in a text box beside the equation). The equations will in some cases be quite complicated and include...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
8
by: vj | last post by:
Hi all, I want to solve the two equations u*tan(u)=w and u^2 + w^2=V^2, where V is a known constant, and u and w are the two unknowns to be determined. Please can someone suggest me how to...
8
by: Blah | last post by:
Hi, this is a small program to print out three lists of values. One is a simple increment count the others are values from two equations. I've run this without problems before but when I've put in...
19
by: TexasNewbie | last post by:
This was originally just a calculator without a decimal point. After I added the decimal, it now tells me invalid second number. //GUI Calculator Program import javax.swing.*; import...
2
by: DaRok28 | last post by:
// Program Description: // This program solves quadratic equations to find their roots. This // program takes values of a, b, and c as input and outputs the root(s). // The user can repeat the...
4
by: sdufoo | last post by:
Hallo guys, I have to solve a system of Differential equations: http://picasaweb.google.de/sdufoo/EcuacionesDiferenciales02/photo#5228386949051570594 these are the equations of an induction...
1
by: HypeBeast McStreetwear | last post by:
Hello everyone. I got a assignment that states. The set of linear equations a11X1 = a12X2 = c1 a21X1 = a22X2 = c2 May be solved using Cramer’s rule: X1 = c1a22 – c2a12 a11a22 –...
3
by: mandy335 | last post by:
public class Calculator { private long input = 0; // current input private long result = 0; // last input/result private String lastOperator = ""; // keeps track of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.