Delphi and Kylix

Moderators: pritaeas
Number of threads: 7264
Number of posts: 19073

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Help in delphi programming Posted by sundog on 22 Oct 2006 at 9:41 AM
Can someone help me to write a program to calculate the value of x for which f(x) = 0 zero for the general quadratic equation. Use the quadratic formula.

a.The program should have input boxes for a, b and c where a, b, and c are the coefficients of x2, x1 and x0

b.And out put the solutions for x.

c.if the solution contains the square root of a negative number then the program should print the message this equation has complex roots and out put the complex roots.


plz i'm really in need of help

Report
Re: Help in delphi programming Posted by zibadian on 22 Oct 2006 at 10:27 AM
: Can someone help me to write a program to calculate the value of x for which f(x) = 0 zero for the general quadratic equation. Use the quadratic formula.
:
: a.The program should have input boxes for a, b and c where a, b, and c are the coefficients of x2, x1 and x0
:
: b.And out put the solutions for x.
:
: c.if the solution contains the square root of a negative number then the program should print the message this equation has complex roots and out put the complex roots.
:
:
: plz i'm really in need of help
:
:
Place a couple of TLabels, TEdits and one TButton on the form. In the TButton.OnClick event code the following:
Use the StrToFloat() to convert the TEdit.Text property to doubles. This will give you the a, b, c coefficients as numbers, so you can calculate with them.
Then comes the maths part, just like you would do on paper. You might need an if-then-else-if-then-else statement to check the various answer possibilities:
  if D < 0 then
  begin
    // Do something
  end else if D = 0 then
  begin
    // Do something else
  end else { no need for another if-then, because if the program gets
             this far, D is not smaller or equal to 0, thus greater than 0 }
  begin
    // Third do something
  end;

Finally use FloatToStr() to convert the results back to strings to show them using another few TLabels.

Check out the help files for more info on these objects, functions.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.