:

:

̳

ֲ ò

________

___________________

:

____ __________ 2009.

____ __________ 2009.

_____________________

ϳ


˳


. BC BILDER 5.0, .

Borland C++ Builder - Borland , C++, Delphi. C++ Builder , .

C++ Builder SDI-, , , () (). , C++ Builder ' ' () (). ϳ .


BORLAND C++ BUILDER

.

Borland C++ Builder - Borland , C++, Delphi. C++ Builder , .

C++ Builder

C++ Builder SDI-, () (). , C++ Builder () (). .

cb200000.gif

.1. C++ Builder

C++ Builder. C++ Builder, . C++ Builder , . C++ Builder , , .

C++ Builder

() (). , . . . , (, , Windows 95 .)

cb200001.gif

. 2.

. , , .

C++ Builder : , .

, , . , .

cb200002.gif

.3.

, . , (, ). (Properties). (published) . published-, (public), , . . . .

, , ( , , , ..).

(Events) , ( , , Windows 95 Windows NT , - ). . C++ Builder , , . , , .

, , , , , C++ Builder . , , . { ... }. , . , .

cb200003.gif

.4. .

, , . , , : ->, :

Edit1->Show();

, *.h , (, ). , , .

, - - . . , View/Project Manager. Project1.cpp.

cb200004.gif

.5.

. . , New Form . , Add , . . , - , , , , . , Remove .

Options , , , , , ( Delphi 2.0, C++ Builder ) .

cb200005.gif

. 6.

C++ Builder , .

, C++ Builder - , C++ Builder.


++ Builder

C++ Builder . , , . , File/New Application.

C++ Builder Project1.cpp, make- Project1.mak. , , , C++ Builder .

cb200006.gif

.7

. :

           .DFM,

           .CPP, C++.

           .H, .

, .

, File/New Form. , . File/New, Forms .

cb200007.gif

.8

, , Compile Compile. , , Run Run. ( ).

, C++ Builder , , . , , Run Run, . Windows.

:

, . File/New Application samp1.cpp, samp.mak. Button, Edit ListBox Standard .

cb200008.gif

. 9.

Edit Text. Caption Button1 "".

OnClick , , OnClick. . C++ Builder . { ... } :

void __fastcall TForm1::Button1Click(TObject *Sender)

{

if (!(Edit1->Text == ""))

{

ListBox1->Items->Add(Edit1->Text);

Edit1->Text = "" ;

}

}

Run Run. - , , .

cb200009.gif

.10. .

, . , Caption , :

cb200010.gif

. 11.

:

void __fastcall TForm1::Button2Click(TObject *Sender)

{

if (!(ListBox1->ItemIndex == -1))

ListBox1->Items->Delete(ListBox1->ItemIndex);

}

:

Close();

, .

, Borland C++ Builder .


˳

#include<iostream.h>

#include<graphics.h>

#include<conio.h>

#include<stdio.h>

#include<ctype.h>

#include<string.h>

#include<math.h>

#include<process.h>

#include<complex.h>

#include<conio.h>

#include<stdlib.h>

#include<iomanip.h>

#define MAX 50

#define ARRAYMAX 10

void initialize();

void menu1();

void menu2();

void data();

void graphch();

void corre();

void mean();

void median();

void graph();

void makegraph(float p[]);

void pie();

void mode();

void variance();

int input();

void correlation();

void regress();

void curvefit();

int midx = getmaxx()/2;

int midy = getmaxy()/2;

int choice1,choice2,choice3,choice4,choice5,choice6,choice7,choice8;

int a[100],b[100],c[100],d[100],e[100],f[100],g[100];

float men,medin,mod,cxy,vx,vy;

int a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1,n1,o1,p1,q1;

long double z1=0,z2=0,z3=0,z4=0,z5=0,z6=0,z7=0,z8=0,byx=0,bxy=0,mx=0,my=0;

static int zzz;

s =0;

float s2 =0.0;

s3 =0;

s1 =0;

float sum =0.0;

float mean,variance,v1,v2,v3;

data();

clrscr();

switch(choice5)

{

case 1:

{

cout<<" Enter the total no of individual observations";

cin>>n;

for(int i=0;i<n;i++)

{

cout<<" X"<<i+1<< " =";

cin>>a[i];

s = s+ a[i];

}

mean = s/n;

for(i=0;i<n;i++)

{

sum = sum+ pow((a[i]-mean),2);

}

clrscr();

cout<<"The values of individual observations are ";

for(i=0;i<n;i++)

cout<<a[i]<<" ";

cout<<endl;

variance = sum/n;

break;

}

case 2:

{

cout<<"Enter the no of data";

cin>>nn;

cout<< "Enter the class interval size";

cin>>ci;

cout<<"Enter the upper most level";

cin>>up;

cout<<" Enter the lowermost level";

cin>>lo;

cout<<"Enter the frequency in order\n";

for(int i=0;i<nn;i++)

{ b[i] = ((up + ci) + up)/2;

up = up + ci;

cout<<" Freq"<<i+1<<" =";

cin>>c[i];

}

for(i=0;i<nn;i++)

{

d[i] = b[i] - b[nn/2];

e[i] = d[i]/ci;

}

for(i=0;i<nn;i++)

cout<<e[i]<<" ";

cout<<endl;

float sum2,sum3,sum4;

sum2 = 0.0;

sum3 =0.0;

sum4 = 0.0;

for(i=0;i<nn;i++)

{

sum2 = sum2 +(c[i]*e[i]);

sum3 = sum3 +(c[i]*pow(e[i],2));

sum4 = sum4+ c[i];

}

cout<<"The sum of f * u = "<<sum2<<endl;

cout<<" The sum of f*u2 = "<<sum3<<endl;

cout<<" The sum of f = "<<sum4<<endl;

v1 = sum3/sum4;

cout<<" The value of 1 = "<<v1<<endl;

v2 = sum2/sum4;

cout<<" The value of 2 = "<<v2<<endl;

v3 = pow(v2,2);

variance = (pow(ci,2)*(v1 -v3));

int u= up;

cout<<"Class\t"<<setw(12)<<"Mid "<<setw(10)<<"Frequency\n";

cout<<"interval\t"<<setw(12)<<"value"<<endl;

for( int k=0;k<nn;k++)

{

cout<<u<<" - "<<u+ci<<"\t"<<setw(12)<<b[k]<<setw(10)<<c[k]<<endl;

u = u+ci;

}

break;

}

case 3:

{ cout<<"Enter the total no of data";

cin>>nn;

char s[20],s4[20];

cout<<" X denotes ";

cin>>s;

cout<<" Frequency denotes ";

cin>>s4;

for(int i=0;i<nn;i++)

{

cout<<"X"<<i+1<<" =";

cin>>a[i];

cout<<"Freq"<<i+1<<" =";

cin>>b[i];

s3 = s3+b[i];

}

cout<<"The sum of f = "<<s3<<endl;

for(i=0;i<nn;i++)

{

s1 =s1+ (a[i]*b[i]);

}

cout<<"The sum of f*x = "<<s1<<endl;

mean = s1/s3;

for(i=0;i<nn;i++)

{

c[i] = pow((a[i]-mean),2);

s2 = s2 +(c[i]*b[i]);

}

cout<<"Mean = "<<mean<<endl;

cout<<"The sum of deviations = "<<s2<<endl;

variance = s2/s3;

cout<<setw(15)<<s<<setw(20)<<s4<<endl<<endl;

for(i=0;i<nn;i++)

{

cout<<setw(15)<<a[i]<<setw(20)<<b[i]<<endl;

}

break;

}

default:

{cout<<" Sorry wrong choice";

getch();

data();

}

}

cout<<" Variance ="<<variance;

getch();

int z=1;

while(z==1||z==2)

{

cout<<"\n\n\n\n\nPress 1 to return to previos menu";

cout<<"\nPress 2 to exit";

cin>>z;

if(z==1)

menu2();

else if(z==2)

exit(0);

else cout<<"Wrong choice";

}

}

char s[20],s1[20];

int input()

{

int n;

gotoxy(2,6);

cout<<"Enter the total no of data";

cin>>n;

cout<<"Enter the variable x and y values\n";

cout<<" X denotes ";

cin>>s;

cout<<" Y denotes ";

cin>>s1;

for(int i=0;i<n;i++)

{

cout<<" X"<<i+1<<" =";

cin>>f[i];

cout<<" Y"<<i+1<<" =";

cin>>g[i];

}

return(n);

}

void correlation()

{

int n;

corre();

initialize();

switch(choice4)

{

case 1:

{

n =input();

clrscr();

cleardevice();

initialize();

settextstyle(7,HORIZ_DIR,0);

outtextxy(50,30,"SCATTER DIAGRAM");

line(50,400,600,400);

line(50,400,50,50);

outtextxy(556,410,s);

settextstyle(7, VERT_DIR,0);

outtextxy(30,375,s1);

settextstyle(7, HORIZ_DIR,0);

for(int i=0;i<n;i++)

{ int x1 = f[i]+ 50;

int y1 = 400- g[i];

setfillstyle(SOLID_FILL,14);

setcolor(14);

circle(x1,y1,1);

floodfill(x1,y1,14);

}

break;

}

case 2:

{// clrscr();

// cleardevice();

float sum2,sum3,sum4,sum5,sum6;

n = input();

sum2 = 0.0;

sum3 =0.0;

sum4 =0.0;

sum5 =0.0;

sum6 =0.0;

clrscr();

cleardevice();

for(int i=0;i<n;i++)

{ sum2 = sum2 + f[i];

sum3 = sum3 + g[i];

}

cout<<setw(15)<<" X "<<setw(20)<<" Y "<<endl<<endl;

for(i=0;i<n;i++)

{

cout<<setw(15)<<f[i]<<setw(20)<<g[i]<<endl;

}

cout<<" The sum of X = "<<sum2<<endl;

cout<<"The sum of Y = "<<sum3<<endl;

float mex = sum2/n;

float mey = sum3/n;

cout<<" The mean of X = "<<mex<<endl;

cout<<"The mean of Y = "<<mey<<endl;

for(i=0;i<n;i++)

{

sum4 = sum4 +((f[i] -mex)*(g[i]-mey));

sum5 = sum5 + pow((f[i]-mex),2);

sum6 = sum6+ pow((g[i]-mey),2);

}

cout<<" The sum of products of deviation from mean of X and Y = "<<sum4<<endl;

cout<<"The sum of squares of deviation from mean of X = "<<sum5<<endl;

cout<<" The sum fo squares of deviation from mean of Y = "<<sum6<<endl;

float cov = sum4/n;

float varx = sqrt(sum5/n);

float vary = sqrt(sum6/n);

float coeff = ((cov/varx)/vary);

cout<<" THE COEFFICIENT OF CORRELATION = "<<coeff<<endl<<endl;

if(coeff<=1 && coeff>= -1)

{

if(coeff == -1)

cout<<" There is perfect negative correlation between X and Y\n";

else if(coeff ==1)

cout<<"There is perfect positive correlation between X and Y\n";

else if(coeff ==0)

cout<<" There is no correlation between X and Y\n";

else if (coeff<0)

cout<<" There is negative correlation between X and Y\n";

else if (coeff>0)

cout<<"There is positive correlation between X and Y\n";

}

else

cout<<"There seems to be a mistake in the data provided since the value of coefficient of correlation does not lie between -1 and 1";

break;

}

default:

{ outtextxy(30,midy +100," Sorry, you have entered the wrong choice");

getch();

cleardevice();

corre();

break;

}

}

getch();

cleardevice();

int z=1;

while(z==1||z==2)

{

cout<<"\n\n\n\n\nPress 1 to return to previos menu";

cout<<"\nPress 2 to exit";

cin>>z;

if(z==1)

menu1();

else if(z==2)

exit(0);

else cout<<"Wrong choice";

}

}

void regress()

{ int n;

float cxy;

initialize();

settextstyle(5, HORIZ_DIR, 0);

setusercharsize(1, 1, 1, 1);

outtextxy(10,midy,"What type of data do you want to enter");

outtextxy(20,midy+30,"1.Discrete data of x and y values\n");

outtextxy(20,midy+60,"2.Data of all summations\n");

cin>>choice7;

// return (choice5);

closegraph();

switch(choice7)

{

case 1:

{

cout<<" Enter the total no of data";

cin>>n;

for(int i=0;i<n;i++)

{ cout<<"X"<<i+1<<" ";

cin>>a[i];

cout<<"Y"<<i+1<<" ";

cin>>b[i];

}

clrscr();

for(i=0;i<n;i++)

{

z1 +=a[i];

z2 +=b[i];

}

mx = z1/n;

my = z2/n;

for( i=0;i<n;i++)

{

z3 += ((a[i]-mx)*(b[i]-my));

z4 += pow((a[i]-mx),2);

z5 += pow((b[i]-my),2);

}

cxy = z3/n;

vx = z4/n;

vy = z5/n;

byx = cxy/vx;

bxy = cxy/vy;

cout<<setw(5)<<"X"<<setw(5)<<" Y"<<endl;

for(i=0;i<n;i++)

{

cout<<setw(5)<<a[i]<<setw(5)<<b[i]<<endl;

}

cout<<"The Line Of Regression of Y on X is \n";

cout<<"\t Y - "<<my<<" = "<<byx<<"( X -"<<mx<<" )";

cout<<endl;

cout<<"The Line Of Regression of X on Y is \n";

cout<<"\t X - "<<mx<<" = "<<bxy<<"( Y -"<<my<<" )";

cout<<endl;

cout<<"\n\nWould you like to estimate values of y or x based on the above equations\n";

cout<<"1. to estimate Y press 1\n";

cout<<"2. To estimate X press 2\n";

cout<<"3. Exit and return to previous menu press 3\n";

cout<<"enter choice?";

cin>>choice8;

clrscr();

float ex,ey;

if(choice8 == 1)

{ char ch = 'y';

while(ch=='y')

{

cout<<" enter the value of X";

cin>>ex;

ey = (byx*(ex- mx)) + my;

cout<<" The estimated value of Y = "<<ey<<endl;

cout<<" do you want to continue";

cin>>ch;

}

}

else if(choice8 == 2)

{ char ch = 'y';

while(ch=='y')

{

cout<<" enter the value of Y";

cin>>ey;

ey = (bxy*(ey- my)) + mx;

cout<<" The estimated value of X = "<<ey<<endl;

cout<<" do you want to continue";

cin>>ch;

}

}

else

break;

break;

}

case 2:

{

cout<<"Enter the total no of data ";

cin>>n;

cout<<" Enter the value of sum of x ";

cin>>z1;

cout<<" Enter the value of sum of y ";

cin>>z2;

cout<<"Enter the value of sum of products of x znd y ";

cin>>z3;

cout<<" Enter the value of sum of squares of x ";

cin>>z4;

cout<<"Enter the values of sum of squares of y ";

cin>>z5;

byx = (n*z3-z1*z2)/(n*z4 - pow(z1,2));

bxy = (n*z3-z1*z2)/(n*z5 - pow(z2,2));

mx = z1/n;

my = z2/n;

clrscr();

cout<<"The sum of x = "<<z1<<endl;

cout<<" The sum of y = "<<z2<<endl;

cout<<" The sum of product of x and y = "<<z3<<endl;

cout<<" The sum of squares of x = "<<z4<<endl;

cout<<" The sum of squares of y = "<<z5<<endl;

cout<<"\n\nThe Line Of Regression of Y on X is \n";

cout<<"\t Y - "<<my<<" = "<<byx<<"( X -"<<mx<<" )";

cout<<endl;

cout<<"The Line Of Regression of X on Y is \n";

cout<<"\t X - "<<mx<<" = "<<bxy<<"( Y -"<<my<<" )";

cout<<endl;

cout<<"\n\nWould you like to estimate values of y or x based on the above equations\n";

cout<<"1. to estimate Y press 1\n";

cout<<"2. To estimate X press 2\n";

cout<<"3. Exit and return to previous menu press 3\n";

cout<<"enter choice?";

cin>>choice8;

clrscr();

float ex,ey;

if(choice8 == 1)

{ char ch = 'y';

while(ch=='y')

{

cout<<" enter the value of X";

cin>>ex;

ey = (byx*(ex- mx)) + my;

cout<<" The estimated value of Y = "<<ey<<endl;

cout<<" do you want to continue";

cin>>ch;

}

}

else if(choice8 == 2)

{ char ch = 'y';

while(ch=='y')

{

cout<<" enter the value of Y";

cin>>ey;

ey = (bxy*(ey- my)) + mx;

cout<<" The estimated value of X = "<<ey<<endl;

cout<<" do you want to continue";

cin>>ch;

}

}

else

break;

break;

}

default:

{

cout<<" Sorry wrong choice";

clrscr();

getch();

regress();

break;

}

}

int z=1;

while(z==1||z==2)

{

cout<<"\n\n\n\n\nPress 1 to return to previos menu";

cout<<"\nPress 2 to exit";

cin>>z;

if(z==1)

menu1();

else if(z==2)

exit(0);

else cout<<"Wrong choice";

}

}

void curvefit()

{ int n;

cout<<" Enter the total no of points ";

cin>>n;

cout<<"Enter the values of x and y coordinates of the points\n";

float a[100],b[100];

for( int i=0;i<n;i++)

{

cout<<" X"<<i+1<<" = ";

cin>>a[i];

cout<<" Y"<<i+1<<" = ";

cin>>b[i];

}

long float aa,bb;

cout<<"\nENTER THE TYPE EQUATION YOU WISH TO CURVE FIT";

cout<<"\nFOR LINEAR FORM, y = ax + b,INPUT 2";

cout<<"\nFOR QUADRATIC FORM, y= ax^2 + bx + c,INPUT 3";

cout<<" \nENTER TYPE ?";

cin>>choice6;

switch(choice6)

{

case 2:

{

for(i=0;i<n;i++)

{

z1 += a[i];

z2 += b[i];

z3 += a[i]*b[i];

z4 += pow(a[i],2);

z5 += pow(b[i],2);

}

float mex = z1/n;

float mey = z2/n;

float cyx = ((z3/n) - mex*mey);

float vx = ((z4/n) - pow(mex,2));

float vy = ((z5/n) - pow(mey,2));

aa = cyx/vx;

bb = mey - mex*aa;

cout<<"\n\n\n a = "<<aa<<"\t b ="<<bb<<endl;

getch();

clrscr();

initialize();

settextstyle(7,HORIZ_DIR,0);

outtextxy(50,30,"BEST CURVE FIT DIAGRAM");

line(50,400,600,400);

line(50,400,50,50);

outtextxy(556,410,"x");

settextstyle(7, VERT_DIR,0);

outtextxy(10,375,"y");

settextstyle(7, HORIZ_DIR,0);

for(i=0;i<n;i++)

{ int x1 = a[i]+50;

int y1 = 400 - b[i];

setfillstyle(SOLID_FILL,14);

setcolor(14);

circle(x1,y1,2);

floodfill(x1,y1,14);

}

setcolor(WHITE);

int x2,y2;

line(50,400,600,400);

line(50,50,50,400);

moveto(50,400);

float y;

for( int i=0;i<198;i++)

{

y = bb + aa*i;

x2 = i+50;

y2 = 400-y;

lineto(x2,y2);

}

break;

}

case 3:

{

for(i=0;i<n;i++)

{

z1 += a[i];

z2 += b[i];

z3 += a[i]*b[i];

z4 += pow(a[i],2)*b[i];

z5 += pow(a[i],2);

z6 += pow(a[i],3);

z7 += pow(a[i],4);

}

long double dx1 = z4*((n*z5)-pow(z1,2));

long double dx2 = z6*((n*z3)-(z1*z2));

long double dx3 = z5*((z3*z1)- (z5 *z2));

long double dx = dx1 - dx2 + dx3;

long double d1 = z7*((n* z5)- pow(z1,2));

long double d2 = z6 *((n*z6)- (z1*z5));

long double d3 = z5*((z6*z1) - pow(z5,2));

long double d = d1-d2 +d3;

long double dy1 = z7*((n*z3) - (z1*z2));

long double dy2 = z6*((n*z6) - (z1*z5));

long double dy3 = z5*((z6*z1)- pow(z5,2));

long double dy = dy1-dy2+dy3;

long double dz1 = z7*((z2*z5) - (z1*z3));

long double dz2 = z6*((z2*z6)- (z1*z3));

long double dz3 = z4*((z6*z1)- pow(z5,2));

long double dz = dz1-dz2+dz3;

long double aa = dx/d;

long double bb = dy/d;

long double cc = dz/d;

cout<<"\n\n\n a = "<<aa<<"\t b = "<<bb<<"\t c = "<<cc<<endl;

getch();

clrscr();

initialize();

settextstyle(7,HORIZ_DIR,0);

outtextxy(50,30,"BEST CURVE FIT DIAGRAM");

line(50,400,600,400);

line(50,400,50,50);

outtextxy(556,410,"x");

settextstyle(7, VERT_DIR,0);

outtextxy(10,375,"y");

settextstyle(7, HORIZ_DIR,0);

for(i=0;i<n;i++)

{ int x1 = a[i]+50;

int y1 = 400 - b[i];

setfillstyle(SOLID_FILL,14);

setcolor(14);

circle(x1,y1,1);

floodfill(x1,y1,14);

}

setcolor(WHITE);

int x2,y2;

line(50,400,600,400);

line(50,50,50,400);

moveto(50,400);

float y;

for( int i=0;i<198;i++)

{

y = (aa*pow(i,2)) +(bb*i) + cc;

x2 = i+50;

y2 = 400-y;

lineto(x2,y2);

}

break;

}

default:

{cout<<"Sorry wrong choice";

getch();

clrscr();

break;

}

// getch();

// closegraph();

}

getch();

closegraph();

//cleardevice();

clrscr();

int z=1;

while(z==1||z==2)

{

cout<<"\n\n\n\n\nPress 1 to return to previos menu";

cout<<"\nPress 2 to exit";

cin>>z;

if(z==1)

menu1();

else if(z==2)

exit(0);

else cout<<"Wrong choice";

}

getch();

}


(The main menu)


(Screen 2 General statistics menu)


BORLAND C++ Bilder BGI.

³ ( ).


˳

1. .., .. . ., 1992. 240 .

2. . /++. ., 1995. 368 .

3. . Borland C++. ., 1996. 400 .

4. .. ++ - . ., 1996. 448 .

5. Borland C++ 4.0. ., 1994. 256 .





2010