Sie sind auf Seite 1von 64

LAB1

/*****************************************************************************
title: area
programmer: fatin nur'ain binti mohamad zaini
filename: LAB1
*****************************************************************************/
#include<iostream.h>
main()
{
double area;
area=1/2.0*10*10;
cout<<"your Area="<<area;
return 0;
}

LAB2
/*****************************************************************************
title: input and output <area>
programmer: fatin nur'ain binti mohamad zaini
filename: LAB2
*****************************************************************************/
#include<iostream.h>
main()
{
double area,base,height;
cout<<"pls enter base?";
cin>>base;
cout<<"pls enter height?";
cin>>height;
area=1/2.0*base*height;
cout<<"your area="<<area;
return 0;
}

LAB3a
/*****************************************************************************
Title: Latit And Dipat
programmer: fatin nur'ain binti mohamad zaini
filename: LAB3a
*****************************************************************************/
#include <iostream.h>
#include <math.h>
main( )
{
double lat,dip,brg,dist;
cout<<"\n Distance ? " ;
cin>> dist;
cout<<"\n Bearing ?";
cin>> brg ;
lat=dist*cos(brg*3.1415926535897932384626433832795/180);
dip=dist*sin(brg*3.1415926535897932384626433832795/180) ;
cout<<"\n Latit : "<< lat;
cout<<"\n Dipat : "<< dip;
return 0;
}
3

LAB3b
/*****************************************************************************
title: math function <bearing and distance>
programmer: fatin nur'ain binti mohamad zaini
filename: LAB3b
*****************************************************************************/
#include<iostream.h>
#include<math.h>
main()
{
double lat,dip,brg,dist,pi;

cout<<"\n Distance?";
cin>>dist;
cout<<"\n Bearing?";
cin>>brg;

pi=3.1415926535897932384626433832795;
lat=dist*cos(brg*pi/180);
dip=dist*sin(brg*pi/180);

cout<<"\n Latit="<<lat;
cout<<"\n Dipat="<<dip;

return 0;
}

LAB3c
/*****************************************************************************
title: math function <bearing and distance>
programmer: fatin nur'ain binti mohamad zaini
filename: LAB3c
*****************************************************************************/
#include <iostream.h>
#include <math.h>
main( )
{
double lat,dip,brg,dist,pi,brgRd;

cout<<"\n Distance ? " ;


cin>> dist;
cout<<"\n Bearing ?";
cin>> brg ;

brgRd= brg*3.1415926535897932384626433832795/180 ;
lat=dist*cos(brgRd);
dip=dist*sin(brgRd) ;

cout<<"\n Latit = "<< lat;


cout<<"\n Dipat = "<< dip;
cout<<"\n Brg = "<< brg;

return 0;
}

LAB3d
/*****************************************************************************
title: clear screen
programmer: fatin nur'ain binti mohamad zaini
filename: LAB3d
*****************************************************************************/
#include <iostream.h>
#include <math.h>
#include <conio.h>
main( )
{
char yn;
double lat,dip,brg,dist,pi,brgRd;

top :
clrscr();

cout<<"\n Distance ? " ;


cin>> dist;
cout<<"\n Bearing ?";
cin>> brg ;
8

brgRd= brg*3.1415926535897932384626433832795/180 ;
lat=dist*cos(brgRd);
dip=dist*sin(brgRd) ;

cout<<"\n Distance =\t"<< dist;


cout<<"\n Bearing =\t"<< brg;
cout<<"\n Bearing in Radian =\t"<< brgRd;
cout<<"\n Latit =\t"<< lat;
cout<<"\n Dipat =\t"<< dip;

cout<<"\n Do you like to try agian [Y/N]?";


cin>>yn;
if(yn=='Y'||yn=='y')goto top;

return 0;
}

LAB3e
/*****************************************************************************
title: area
programmer: fatin nur'ain binti mohamad zaini
filename: LAB3e
*****************************************************************************/
#include<iostream.h>
#include<math.h>
main()
{
double area,base,height,angle,angleRad;

cout<<"\n pls enter base?";


cin>>base;
cout<<"\n pls enter height?";
cin>>height;
cout<<"\n pls enter angle?";
cin>>angle;

angleRad=angle*3.1415926535897932384626433832795/180;
area=1/2.0*base*height*sin(angleRad);
10

cout<<"\n base="
cout<<"\n Brg in Radian=\t"<<brgRd;
cout<<"\n Latit=\t"<<lat;

cout<<"\n Dipat=\t"<<dip;
cout<<"\n your area="<<area;

return 0;
}

11

LAB3f
/*****************************************************************************
title:
programmer: fatin nur'ain binti mohamad zaini
filename: LAB3f
*****************************************************************************/
#include <iostream.h>
#include <math.h>
#include <conio.h>
main()
{
char yn;
double area,base,height,angle,anglerd;

top :

cout<<"pls enter base?";


cin>>base;
cout<<"pls enter height?";
cin>>height;
cout<<"pls enter angle?";
12

cin>>angle;
anglerd = angle*3.1415926535897932384626433832795/180 ;
area=1/2.0*base*height*sin(anglerd);

cout<< "\n your area="<<area;


cout<< "\n your base="<<base;
cout<< "\n your height="<<height;
cout<< "\n your angle="<<angle;

cout<<"\n Do you like to try agian [Y/N]?";


cin>>yn;
if(yn=='Y'||yn=='y')goto top;

return 0;
}

13

LAB4
/*****************************************************************************
title: angle and distance
date: 28/03/2012
programmer: fatin nur'ain binti mohamad zaini
filename: LAB4
*****************************************************************************/
#include<iostream.h>
#include<math.h>
#include<conio.h>
main()
{
//variable declaration
const double pi=3.1415926535897932384626433832795;
double angle_A,angle_B,angle_C;
double dist_a,dist_b,dist_c;
double degA,minA,secA;
double degB,minB,secB;
int degI,minI;
double min,sec;

14

//input
cout<<"\n Enter angle A: ";
cin>>degA>>minA>>secA;
cout<<"\n Enter angle B: ";
cin>>degB>>minB>>secB;
cout<<"\n Enter distance a: ";
cin>>dist_a;
cout<<"\n Enter distance b: ";
cin>>dist_b;

//process
angle_A=degA+minA/60.0+secA/3600.0;
angle_B=degB+minB/60.0+secB/3600.0;
angle_C=180-(angle_A+angle_B);
angle_C=angle_C*pi/180.0;
dist_c=sqrt(pow(dist_a,2)+pow(dist_b,2)-2*dist_a*dist_b*cos(angle_C));

//change deg decimal to deg min sec


degI=angle_C;
min=(angle_C-degI)*60.0;

15

minI=min;
sec=(min-minI)*60.0;

//output
cout<<"\n Angle A: "<<degA<<char(176)<<" "<<minA<<"' "<<secA<<"\"";
cout<<"\n Angle B: "<<degB<<char(176)<<" "<<minB<<"' "<<secB<<"\"";
cout<<"\n Angle C: "<<degI<<char(176)<<" "<<minI<<"' "<<sec<<"\"";
cout<<"\n Distance a: "<<dist_a;
cout<<"\n Distance b: "<<dist_b;
cout<<"\n Distance c: "<<dist_c;

return 0;
}

16

LAB 5
/*****************************************************************************
title: triangulation
>can be used for hydrography<
date: 04/04/2012
programmer: fatin nur'ain binti mohamad zaini
filename

: LAB 5

*****************************************************************************/
#include<iostream.h>
#include<math.h>
#include<conio.h>
main()
{
//variable declaration
double c,degA,minA,secA,degB,minB,secB,angA,angB,angC,b,a,area,area2,s;
const double pi=3.1415926535897932384626433832795;
char YN;

top:
clrscr();

17

cout<<" \n Enter angle A: ";


cin>>degA>>minA>>secA;
cout<<" \n Enter angle B: ";
cin>>degB>>minB>>secB;
cout<<" \n Enter distance c: ";
cin>>c;

angA=degA+minA/60.0+secA/3600.0;
angB=degB+minB/60.0+secB/3600.0;
angC=180-(angA+angB);
b=c*sin(angB*pi/180)/sin(angC*pi/180);
a=b*sin(angA*pi/180)/sin(angB*pi/180);
area=1/2.0*a*b*sin(angC*pi/180);
s=(a+b+c)/2.0;
area2=sqrt(s*(s-a)*(s-b)*(s-c));

cout<<" \n Angle A= "<<degA<<" "<<minA<<"' "<<secA<<"\"";


cout<<" \n\n Angle B= "<<degB<<" "<<minB<<"' "<<secB<<"\"";
cout<<" \n\n Angle C= "<<angC;
cout<<" \n\n Distance b= "<<b;
cout<<" \n\n Distance a= "<<a;

18

cout<<" \n\n Area of triangle: "<<area;


cout<<" \n\n Area of triangle2: "<<area2;

cout<<" \n\n Do you like to try again [Y/N]? ";


cin>>YN;
if(YN=='Y'||YN=='y') goto top;

return 0;
}

19

LAB6a
/*****************************************************************************
title:lab6(for)
date: 02.05.2012
programmer: fatin nur'ain binti mohamad zaini
filename:LAB6a
*****************************************************************************/
#include<iostream.h>
#include<math.h>
#include<conio.h>
main()
{

//variable declaration
double dist,brg,sumDist=0.0;
int i,j=0;

for(i=1;i<=3;i++)
{
//input
cout<<"\n Enter distance: ";
20

cin>>dist;
cout<<"\n Enter bearing: ";
cin>>brg;

//process
j=j+1;
sumDist=sumDist+dist;
}

//output
cout<<"\n Number of data: "<<j;
cout<<"\n Total distance: "<<sumDist;

return 0;
}

21

LAB6b
/*****************************************************************************
title:lab6(for)
date: 02.05.2012
programmer: fatin nur'ain binti mohamad zaini
filename:LAB6b
*****************************************************************************/
#include <iostream.h>
#include <math.h>
#include <conio.h>
main()
{

char yn;
double stn ;
double dist,brg, dip,lat;
double deg,min, sec;

top:

double sumdist=0.0,sumlat=0.0,sumdip =0.0;


22

int i, j=0;
const double pi = 3.1415926535897932384626433832795 ;

clrscr();

cout<<" \n Enter number of station =";


cin>> stn ;

for(i=1;i<=stn;i++)
{
//input
cout<<" \n Enter distance =";
cin>> dist ;
cout<<" \n Enter bearing = ";
cin>> deg >> min >> sec;
brg = deg+min/60.0+sec/3600.0;

//process
brg = brg * pi/180.0;
lat= dist *cos(brg);

23

dip = dist * sin(brg);

j = j +1;
sumdist = sumdist + dist;
sumlat = sumlat + lat ;
sumdip = sumdip + dip ;

cout<<"\n distance = "<< dist;


cout<<"\n bearing = "<< deg<<char(176)<<" "<<min <<"' "<< sec << "\"";
cout<<"\n Latit = "<< lat;
cout<<"\n Dipat = "<< dip;
}

cout<<"\n number of data = "<< j;


cout<<"\n total distance = "<< sumdist;
cout<<"\n total latitude = "<< sumlat;
cout<<"\n total departure = "<< sumdip;

cout<<"\n Do you like to try agian [Y/N]?";


cin>>yn;

24

if(yn=='Y'||yn=='y')goto top;
return 0;
}

25

LAB6c
/*****************************************************************************
title: for and clear screen
date: 02.05.2012
programmer: fatin nur'ain binti mohamad zaini
filename:LAB6c
*****************************************************************************/
#include <iostream.h>
#include <math.h>
#include <conio.h>
main()
{

char yn;
double dist,brg, dip,lat;
double deg,min, sec;
double sumdist=0.0,sumlat=0.0,sumdip =0.0;
int i, j=0;
const double pi = 3.1415926535897932384626433832795 ;

top :
26

clrscr();
for(i=1;i<=3;i++)
{
//input
cout<<" \n Enter distance =";
cin>> dist ;
cout<<" \n Enter bearing = ";
cin>> deg >> min >> sec;
brg = deg+min/60.0+sec/3600.0;

//process
brg = brg * pi/180.0;
lat= dist *cos(brg);
dip = dist * sin(brg);

j = j +1;
sumdist = sumdist + dist;
sumlat = sumlat + lat ;
sumdip = sumdip + dip ;

cout<<"\n distance = "<< dist;

27

cout<<"\n bearing = "<< deg<<char(176)<<" "<<min <<"' "<< sec << "\"";
cout<<"\n Latit = "<< lat;
cout<<"\n Dipat = "<< dip;
}

cout<<"\n number of data = "<< j;


cout<<"\n total distance = "<< sumdist;
cout<<"\n total latitude = "<< sumlat;
cout<<"\n total departure = "<< sumdip;

cout<<"\n Do you like to try agian [Y/N]?";


cin>>yn;
if(yn=='Y'||yn=='y')goto top;

return 0;
}

28

LAB7
/*****************************************************************************
title: array
date: 09/05/2012
programmer: fatin nur'ain binti mohamad zaini
filename: LAB7
*****************************************************************************/
#include<iostream.h>
#include<math.h>
#include<conio.h>
main()
{
//variable declaration
double base[10],ht[10],area[10];
int i,num;

//input
cout<<"\n Please enter number of triangle to compute: ";
cin>>num;

29

for(i=1;i<=num;i++)
{
cout<<"\n\n Please enter base: ";
cin>>base[i];
cout<<"\n Pleae enter height: ";
cin>>ht[i];

area[i]=1/2.0*base[i]*ht[i];

cout<<"\n Your base: "<<base[i];


cout<<"\n Your height: "<<ht[i];
cout<<"\n Your area: "<<area[i];
}

cout<<"\n Your last i value: "<<i;

for(i=1;i<=num;i++)
{
cout<<"\n\n Base: "<<base[i];
cout<<"\n Height: "<<ht[i];
cout<<"\n Area: "<<area[i];

30

return 0;
}

31

LAB7b
/*****************************************************************************
title: array
date: 09/052012
programmer: fatin nur'ain binti mohamad zaini
filename: LAB7b
*****************************************************************************/
#include<iostream.h>
#include<math.h>
#include<conio.h>

main()
{

//variable declaration
double dist[25],brg[25],lat[25],dip[25],sumDist=0.0;
double deg[25],min[25],sec[25];
double totalLat,totalDip;
const double pi=3.1415926535897932384626433832795;
int stn,i,j=0;
char YN;
32

totalLat=0.0;
totalDip=0.0;

//label
top:
clrscr();

//input
cout<<"\n Enter number of station: ";
cin>>stn;

for(i=1;i<=stn;i++)
{
//input
cout<<"\n\n Enter distance: ";
cin>>dist[i];
cout<<"\n Enter bearing: ";
cin>>deg[i]>>min[i]>>sec[i];

//process

33

brg[i]=deg[i]+(min[i]/60.0)+(sec[i]/3600.0);
brg[i]=brg[i]*pi/180.0;
j=j+1;
sumDist=sumDist+dist[i];
lat[i]=dist[i]*cos(brg[i]);
dip[i]=dist[i]*sin(brg[i]);
totalLat=totalLat+lat[i];
totalDip=totalDip+dip[i];

//output
cout<<"\n Bearing= "<<deg[i]<<char(176)<<" "<<min[i]<<"' "<<sec[i]<<"\"";
cout<<"\n Distance= "<<dist[i];
cout<<"\n Latitude="<<lat[i];
cout<<"\n Departure="<<dip[i];
}

for(i=1;i<=stn;i++)
{
//output
cout<<"\n\n Bearing= "<<deg[i]<<char(176)<<" "<<min[i]<<"' "<<sec[i]<<"\"";
cout<<"\n Distance= "<<dist[i];

34

cout<<"\n Latitude="<<lat[i];
cout<<"\n Departure="<<dip[i];
}

//output
cout<<"\n\n Number of data: "<<j;
cout<<"\n Total distance: "<<sumDist;
cout<<"\n Total latitude: "<<totalLat;
cout<<"\n Total departure: "<<totalDip;

cout<<" \n\n Do you like to try again [Y/N]? ";


cin>>YN;
if(YN=='Y'||YN=='y') goto top;

return 0;
}

35

LAB8
/****************************************************************************
title: corrected angle
date: 16.05.2012
programmer: fatin nur'ain binti mohamad zaini
filename: LAB8
*****************************************************************************/
#include<iostream.h>
#include<math.h>
#include<conio.h>
main()
{
//variable declaration
double deg[50],min[50],sec[50],sumdeg[50],total,error;
double corr,corDeg[50],total2,Nmin[50],Nsec[50];
int i,stn,Ideg[50],INmin[50],INsec[50];
total=0.0;

//input
cout<<"\n Please enter number of station: ";
cin>>stn;
36

for(i=1;i<=stn;i++)
{
cout<<"\n\n Enter angle at station [deg|min|sec] "<<i<<":";
cin>>deg[i]>>min[i]>>sec[i];
sumdeg[i]=deg[i]+(min[i]/60.0)+(sec[i]/3600.0);
total=total+sumdeg[i];
error=(((2*stn)-4)*90)-total;
corr=error/stn;
}

cout<<"\n Your sum of angle= "<<total;


cout<<"\n Your error = "<<error;

total2=0.0;
for(i=1;i<=stn;i++)
{
corDeg[i]=sumdeg[i]+corr;
total2=total2+corDeg[i];
cout<<"\n\n Your correction ="<<corDeg[i];
cout<<"\n Your sum of angle ="<<total2;
}

37

cout<<"\n\n Your sum of corrected angle = "<<total2;

for(i=1;i<=stn;i++)
{
Ideg[i]=corDeg[i];
Nmin[i]=(corDeg[i]-Ideg[i])*60.0;
INmin[i]=Nmin[i];
Nsec[i]=(Nmin[i]-INmin[i])*60.0;
INsec[i]=Nsec[i];

cout<<"\n\n Input angle "<<i<<"="<<deg[i]<<char(176)<<min[i]<<"'"<<sec[i]<<"\"";


cout<<"\n Correted angle "<<i<<"="<<Ideg[i]<< char(176)<<INmin[i]<<" ' "<< INsec[i]
<<"\" ";
}

return 0;
}

38

LAB9
/*****************************************************************************
title: for and array
<area of polygon>
date: 23.05.2012
programmer: fatin nur'ain binti mohamad zaini
filename: LAB9
*****************************************************************************/
#include<iostream.h>
#include<math.h>
#include<conio.h>
main()
{
double x[50],y[50],sumA,sumB,area,maxX,minX,maxY,minY;
int i,stn;

//input
cout<<"\n Please enter number of station: ";
cin>>stn;

sumA=0.0;
39

sumB=0.0;

for(i=1;i<=stn;i++)
{
cout<<"\n Enter coordinate X and Y ["<<i<<"] :";
cin>>x[i]>>y[i];
}

for(i=1;i<=stn;i++)
{
sumA=sumA+(x[i]*y[i+1]);
sumB=sumB+(x[i+1]*y[i]);
}

sumA=sumA+(x[stn]*y[1]);
sumB=sumB+(x[1]*y[stn]);
area=(sumA-sumB)/2.0;

cout<<"\n Your area of polygon: "<<abs(area)<<"m"<<char(178);

maxX=x[1];

40

minX=x[1];
maxY=y[1];
minY=y[1];

for(i=1;i<=stn;i++)
{
if(x[i]>maxX) maxX=x[i];
if(x[i]<minX) minX=x[i];
if(x[i]>maxY) maxY=y[i];
if(x[i]<minY) minY=y[i];
}

cout<<"\n\n Maximum X= "<<maxX;


cout<<"\n Minimum X= "<<minX;
cout<<"\n Maximum Y= "<<maxY;
cout<<"\n Minimum Y= "<<minY;

return 0;
}

41

LAB10
/*****************************************************************************
title: file
date: 06.06.2012
programmer: fatin nur'ain binti mohamad zaini
filename: LAB10
*****************************************************************************/
#include<iostream.h>
#include<math.h>
#include<fstream.h>
#include<conio.h>
main()
{

double deg[30],min[30],sec[30],dist[30];
double lat[30],dip[30],brg[30];
const double pi=3.1415926535897932384626433832795;
char file[30],cuba,trv[30];
int i,stn;

top:
42

cout<<"\n\a Please enter filename: ";


cin>>file;

ifstream fp1;
fp1.open(file);
if(!fp1)
{
cout<<"\n\a Your file "<<file<<" cannot be open! ";
cout<<"\n Do you like to try again [Y|N]? ";
cin>>cuba;
if(cuba=='y'||cuba=='Y')goto top;
return 0;
}

fp1>>stn;
cout<<"\n Your station= "<<stn;
fp1>>trv;
cout<<"\n Type of project: "<<trv;

for(i=1;i<=stn;i++)

43

{
fp1>>deg[i]>>min[i]>>sec[i]>>dist[i];
cout<<"\n "<<deg[i]<<" " <<min[i]<<" "<<sec[i]<<"\t "<<dist[i];
brg[i]=deg[i]+(min[i]/60.0)+(sec[i]/3600.0);
brg[i]=brg[i]*pi/180.0;
lat[i]=dist[i]*cos(brg[i]);
dip[i]=dist[i]*sin(brg[i]);
cout<<"\n Latitude="<<lat[i];
cout<<"\n Departure="<<dip[i];
}

fp1.close();

return 0;
}

44

LAB11
/*****************************************************************************
title : area to compute
date : 13 06 2012
programmer : fatin nurain binti mohamad zaini
filename : LAB11
*****************************************************************************/
#include <iostream.h>
#include <math.h>
#include <fstream.h>
#include <conio.h>
main ()
{
double base[4],ht[4],area[4];
int i,num;
char fil[30],title1[30],title2[30],title3[30],title4[30],yn,fil2[30];

top:

cout<<"\n enter file name = " ;


cin>> fil ;
45

ifstream fp1;
fp1.open(fil);
if(!fp1)
{

cout<<"\n your file "<< fil <<" cannot be open ! " ;


cout<<"\n Do you like to try agian [Y/N]?";
cin>>yn;
if(yn=='Y'||yn=='y')goto top;
return 0;
}

fp1>>title1;
fp1>>num>>title2>>title3>>title4;

for (i=1; i<=num; i++)


{
fp1>>base[i]>>ht[i];
cout<<"\n your base & height read =" << base[i] <<" "<<ht[i] ;

46

for (i=1; i<=num; i++)


{
area[i]= 1/2.0*base[i]*ht[i];
cout<<"\n your area =" << area[i] ;
}

top2:

cout<<"\n enter output filename ? ";


cin>>fil2;

ofstream fp2;
fp2.open(fil2);
if(!fp2)
{
cout<<"\n your file "<< fil2 <<" cannot be open ! " ;
cout<<"\n Do you like to try agian [Y/N]?";
cin>>yn;
if(yn=='Y'||yn=='y')goto top2;

47

return 0;
}

for (i=1; i<=num; i++)


{
fp2<<"\n your area= "<< area[i] ;
cout<<"\n the value of i in the loop ="<<i;
}

cout<<"\n the last value of i ="<<i;

return 0;
}

48

LAB11a
/*****************************************************************************
title : area to compute<write to file>
date : 13 06 2012
programmer : fatin nurain binti mohamad zaini
filename : LAB11a
*****************************************************************************/
#include <iostream.h>
#include <math.h>
#include <fstream.h>
#include <conio.h>
main ()
{
double base[4],ht[4],area[4];
int i,num;
char fil[30],title1[30],title2[30],title3[30],title4[30],yn,fil2[30];

top:
cout<<"\n enter file name = " ;
cin>> fil ;
49

ifstream fp1;
fp1.open(fil);
if(!fp1)
{
cout<<"\n your file "<< fil <<" cannot be open ! " ;

cout<<"\n Do you like to try agian [Y/N]?";


cin>>yn;
if(yn=='Y'||yn=='y')goto top;
return 0;
}

fp1>>title1;
fp1>>num>>title2>>title3>>title4;

for (i=1; i<=num; i++)


{
fp1>>base[i]>>ht[i];
cout<<"\n your base & height read =" << base[i] <<" "<<ht[i] ;
}

50

for (i=1; i<=num; i++)


{
area[i]= 1/2.0*base[i]*ht[i];
cout<<"\n your area =" << area[i] ;
}

top2:
cout<<"\n enter output filename ? ";
cin>>fil2;

ofstream fp2;
fp2.open(fil2);
if(!fp2)
{
cout<<"\n your file "<< fil2 <<" cannot be open ! " ;
cout<<"\n Do you like to try agian [Y/N]?";
cin>>yn;
if(yn=='Y'||yn=='y')goto top2;
return 0;
}

51

for (i=1; i<=num; i++)


{
fp2<<"\n your area= "<< area[i] ;
cout<<"\n the value of i in the loop ="<<i;
}
cout<<"\n the last value of i ="<<i;

return 0;
}

52

FINAL PROJECT
/*****************************************************************************
title: transition curve
date: 27 06 2012
programmer: fatin nur'ain binti mohamad zaini
filename: FINAL PROJECT
*****************************************************************************/
#include<iostream.h>
#include<math.h>
#include<fstream.h>
#include<conio.h>
main()
{
double Lt,v,R,a,cho;
double IP,T1,T2;
double S,IT,ang,degA,minA,secA;
double pt[50],L[50];
double secD[50],angD[50],new_angD[50],minD_d[50],secD_d[50];
const double pi=3.1415926535897932384626433832795;
char yn,file[30],file2[30],title1[30],title2[30],title3[30];
int stn,i,degD[50],minD[50];
53

top:
clrscr();

cout<<"\n\t THIS PROGRAM IS DESIGNATED TO CALCULATE TRANSITION CURVE. ";

cout<<"\n\n\a Please enter filename to be read: ";


cin>>file;

ifstream noen;
noen.open(file);
if(!noen)
{
cout<<"\n\a Your data file "<<file<<" cannot be open! ";
cout<<"\n Do you like to try again [Y|N]? ";
cin>>yn;
if(yn=='y'||yn=='Y')goto top;
return 0;
}

noen>>title1>>title2>>title3;

54

cout<<"\n "<<title1<<" "<<title2<<" "<<title3;


noen>>degA>>minA>>secA;
cout<<"\n Deflection angle :"<<degA<<char(176)<<minA<<"'"<<secA<<"\"";
noen>>R;
cout<<"\n Radius of curvature (in m) :"<<R;
noen>>IP;
cout<<"\n Chainage of intersection point (in m) :"<<IP;
noen>>cho;
cout<<"\n Chord interval (in m) :"<<cho;
noen>>v;
cout<<"\n Design speed (in km/h) :"<<v;
noen>>a;
cout<<"\n Radial acceleration (in m/s"<<char(178)<<") :"<<a;

Lt=pow(v,3)/(pow(3.6,3)*a*R);
S=pow(Lt,2)/(24*R);
ang=degA+(minA/60.0)+(secA/3600.0);
IT=((R+S)*tan((ang*pi/180.0)/2.0))+(Lt/2.0);
T1=IP-IT;
T2=T1+Lt;

55

cout<<"\n\n The length of transition curve: "<<Lt<<"m";


cout<<"\n The value of shift: "<<S<<"m";
cout<<"\n The value of tangent length: "<<IT<<"m";
cout<<"\n The value of chainage 1(CH T1): "<<T1<<"m";
cout<<"\n The value of chainage 2(CH T2): "<<T2<<"m";

cout<<"\n\n Please round off the value of chainage 1(CH T1) ["<<T1<<"] to the\n nearest chord
interval ["<<cho<<"]: ";
cin>>pt[2];

//chainage
cout<<"\n\n Please enter the number of chainage that must be measure\n for transition curve: ";
cin>>stn;

cout<<"\n Chainage 1(CH T1) = Point 1 ";


cout<<"\n Point 1 = "<<T1<<" m";
cout<<"\n Point 2 = "<<pt[2]<<" m";

for(i=3;i<stn;i++)
{
pt[i]=pt[i-1]+cho;

56

cout<<"\n Point "<<i<<" = "<<pt[i]<<" m";


}

cout<<"\n Point "<<i<<" = "<<T2<<" m";

//subchord
L[1]=0.0;
L[2]=pt[2]-T1;

cout<<"\n\n Length of subchord 1 = "<<L[1]<<" m";


cout<<"\n Length of subchord 2 = "<<L[2]<<" m";

for(i=3;i<stn;i++)
{
L[i]=L[i-1]+cho;
L[stn]=L[i]+(T2-pt[i]);

cout<<"\n Length of subchord "<<i<<" = "<<L[i]<<" m";


}

57

cout<<"\n Length of subchord "<<i<<" = "<<L[stn]<<" m";

//deflection angle
degD[1]=0.0;
minD[1]=0.0;
secD[1]=0.0;

cout<<"\n\n Deflection angle 1 = "<<degD[1]<<char(176)<<minD[1]<<"'"<<secD[1]<<"\"";

for(i=2;i<=stn;i++)
{
angD[i]=(1800*pow(L[i],2.0))/(pi*R*Lt);
new_angD[i]=angD[i]/60.0;
degD[i]=new_angD[i];
minD_d[i]=(new_angD[i]-degD[i])*60.0;
minD[i]=minD_d[i];
secD_d[i]=(minD_d[i]-minD[i])*60.0;
secD[i]=secD_d[i];

cout<<"\n

Deflection

angle

"<<i<<"

"<<degD[i]<<char(176)<<minD[i]<<"'"<<secD[i]<<"\"";

58

top2:

cout<<"\n\n Please enter output filename : ";


cin>>file2;

ofstream noen2;
noen2.open(file2);
if(!noen2)
{
cout<<"\n your file "<< file2 <<" cannot be open ! " ;
cout<<"\n Do you like to try again [Y|N]?";
cin>>yn;
if(yn=='Y'||yn=='y')goto top2;
return 0;
}

noen2<<"\n The result for calculation in transition curve. ";

noen2<<"\n\n The length of transition curve

:"<<Lt<<"m";

59

noen2<<"\n The value of shift

:"<<S<<"m";

noen2<<"\n The value of tangent length

:"<<IT<<"m";

noen2<<"\n The value of chainage 1(CH T1)

:"<<T1<<"m";

noen2<<"\n The value of chainage 2(CH T2)

:"<<T2<<"m";

for(i=1;i<=stn;i++)
{
noen2<<"\n\n Point "<<i<<" = "<<pt[i]<<" m";
noen2<<"\n Length of subchord "<<i<<" = "<<L[i]<<" m";
noen2<<"\n Deflection angle "<<i<<"
="<<degD[i]<<char(176)<<minD[i]<<"'"<<secD[i]<<"\"";
}

return 0;
}

60

SAMPLE DATA FOR TRANSITION CURVE


Data for curve
10 00 00
400
1800.00
10
60
0.3

61

SAMPLE RESULT FOR TRANSITION


CURVE

62

RUN THE PROGRAM FOR FINAL


PROJECT

63

64

Das könnte Ihnen auch gefallen