Re: Logical expressions help! (newbie)



Tom de Neef wrote:
"Nektarios - Greece" <eizo5@xxxxxxxxxxxx> schreef in bericht news:e7mg3j$2t2$1@xxxxxxxxxxxxxxxxxxxxxx
Suppose you have a mathematical expression valid if 0,5 < x < 2
where x is a real number.
Suppose again that you have a second mathematical expression valid if 0<x<1,5.

Now let the user enter x in a Edit box.
If user enters x=1 the program should inform him that both mathematical expressions works for him and let him choose which mathematical expression works for him. Another option is that the program will present both solutions informing the user that both will work for him.

The mathematical expressions calculate "Nusselt number" , a number to calculate heat transfer phenomena. The mathematical expressions do NOT find the same Nusselt number. A 10% deviation is present.
Example
Nusselt1=2*x+3
Nusselt2=5*x-1


THE QUESTION :
How can i make the program to find out that both mathematical expressions are valid ( "if then else" won't work in case of x=1 ) and inform the user about that ? After that, the program should present the two results in the same form.


I'm not sure I understand what difficulty you see. You have to
1- obtain user input
2- determine which 'mathematical expressions' are valid for that input
3- inform the user about it.

1: put Tedit control on form and a button to signal that input is complete. In button's OnClick: obtain x:=FloatToStr(edit1.text,... and do the next steps.
2: how many of these 'mathematical expressions' are there? If it is just two or three I would declare functions to handle each of them from scratch. If it is dozens, we need to look into it further.
function ValidRange1(x : extended) : boolean;
begin result:= (x>=0.5) AND (x<=2) end;
function ValidRange2(x : extended) : boolean;
begin result:= (x>=0) AND (x<=1.5) end;
etc.
3: if ValidRange1(x) AND ValidRange2(x)
then tell user he has to make a choice
else if NOT ValidRange1(x) AND NOT ValidRange2(x)
then tell user there is no function
else tell user he has no choice.

Now tell us in more detail where the difficulty lies.



To answer where is the difficult part for me is simple : I am a newbie.
The math expressions to choose from are 4. So i will use boolean functions like you wrote. Thank you Tom for your help.
.


Quantcast