hi guys...
i haven't time to sleep cuz i need to make a program "Method of chords"....
dates i enter in Edit1
i need to use TParser but i don't know how to use it...
CAN SOMEBODY HELP ME?
TY
here is the code:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "metod_hord.h"
#include "Classes.hpp"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "sSkinManager"
#pragma link "sBitBtn"
#pragma link "sButton"
#pragma resource "*.dfm"
TForm1 *Form1;
float a1,b1,c1;
TParser *pars = new TParser(); //
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
float __fastcall f(float x)
{
if (Form1->ComboBox1->ItemIndex==0){
return pow(x,3)-2*pow(x,2)-6*x-1;
}
if (Form1->ComboBox1->ItemIndex==1){
return pow(x,3)-pow(x,2)+3;
}
if (Form1->ComboBox1->ItemIndex==2){
return sin(x);
}
if (Form1->ComboBox1->ItemIndex==2){
return cos(x);
}
}
//---------------------------------------------------------------------------
float __fastcall hord(float m, float n, float e)
{
while (fabs(n-m)>e)
{
m=n-(m-n)*f(n)/(f(n)-f(m));
n=m-(m-n)*f(m)/(f(m)-f(n));
}
return n;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
float f,a,b,e;
if ((Edit2->Text=="")||(Edit3->Text=="")|| (Edit4->Text=="")|| (ComboBox1->ItemIndex==-1)){
ShowMessage("enter corrrect dates");
}
a=StrToFloat(Edit2->Text);
b=StrToFloat(Edit3->Text);
e=StrToFloat(Edit4->Text);
Edit1->Text=FloatToStrF(hord(a,b,e),ffGeneral, 5, 2);
Edit1->Visible=true;
if ((hord(a,b,e)<=-0.3)||(hord(a,b,e)==0.3)) {
Edit1->Text= "no result";
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N6Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N4Click(TObject *Sender)
{
TStringList * List=new TStringList;
List->Add(Edit1->Text);
List->SaveToFile("1.txt");
delete List;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N5Click(TObject *Sender)
{
if( SaveDialog1->Execute() )
{
TStringList * List=new TStringList;
List->Add(Edit1->Text);
List->SaveToFile("1.txt");
delete List;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn1Click(TObject *Sender)
{
Edit1->Clear();
Edit2->Clear(); // cleare all
Edit3->Clear();
Edit4->Clear();
ComboBox1->ItemIndex=-1;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N11Click(TObject *Sender)
{
Form2->Show(); //open "About "
}
//---------------------------------------------------------------------------
void __fastcall TForm1::N10Click(TObject *Sender)
{
ShellExecute(Handle, L"open", L"Help.chm", NULL, NULL, SW_SHOWNORMAL); //open "Help"