#include <iostream.h>
#include<string.h>
#include<conio.h>
void main()
{
double batas1[10],batas2[10],ba[10],ba1[10],ba2[10],ba3[10],input[10],x,y,n,s,atot[30];
double miu[10][10],u[30],z1[30],z2[30],az1[30],az2[30],aztot[3];
int a,b,c;
char tipe[20][20],konf;
ulang:
clrscr();
strcpy(tipe[0],"kecepatan");
strcpy(tipe[1],"jarak");
strcpy(tipe[2],"rem");
for(a=0;a<=2;a++)
{
cout<<"----------------------------"<<endl;
cout<<"masukkan batas bawah "<<tipe[a]<<" : ";
cin>>batas1[a];
cout<<"masukkan batas atas "<<tipe[a]<<" : ";
cin>>batas2[a];
ba[a]=(batas2[a]-batas1[a])/4;
ba1[a]=batas1[a]+ba[a];
ba2[a]=ba1[a]+ba[a];
ba3[a]=ba2[a]+ba[a];
cout<<"batas antara 1 : "<<ba1[a]<<endl;
cout<<"batas antara 2 : "<<ba2[a]<<endl;
cout<<"batas antara 3 : "<<ba3[a]<<endl;
cout<<endl;
}
//input
cout<<"\n\n*************************\n\n"<<endl;
cout<<"masukkan kecepatan : ";cin>>input[0];
cout<<"masukkan jarak : ";cin>>input[1];
cout<<"\n\n*************************\n\n"<<endl;
//miu
for(a=0;a<=1;a++)
{
if (input[a]>=batas1[a] && input[a]<ba1[a])
{n=input[a];x=batas1[a];y=ba1[a];
miu[a][1]=(y-n)/(y-x);
miu[a][2]=(n-x)/(y-x);
}
else if (input[a]>=ba1[a] && input[a]<ba2[a])
{n=input[a];x=ba1[a];y=ba2[a];
miu[a][2]=(y-n)/(y-x);
miu[a][3]=(n-x)/(y-x);
}
else if (input[a]>=ba2[a] && input[a]<ba3[a])
{n=input[a];x=ba2[a];y=ba3[a];
miu[a][3]=(y-n)/(y-x);
miu[a][4]=(n-x)/(y-x);
}
else if (input[a]>=ba3[a] && input[a]<=batas2[a])
{n=input[a];x=ba3[a];y=batas2[a];
miu[a][4]=(y-n)/(y-x);
miu[a][5]=(n-x)/(y-x);
}
}
cout<<"miu sangat lambat : "<<miu[0][1]<<endl;
cout<<"miu agak lambat : "<<miu[0][2]<<endl;
cout<<"miu sedang : "<<miu[0][3]<<endl;
cout<<"miu agak cepat : "<<miu[0][4]<<endl;
cout<<"miu sangat cepat : "<<miu[0][5]<<endl<<endl;
cout<<"miu sangat dekat : "<<miu[1][1]<<endl;
cout<<"miu agak dekat : "<<miu[1][2]<<endl;
cout<<"sedang : "<<miu[1][3]<<endl;
cout<<"miu agak jauh : "<<miu[1][4]<<endl;
cout<<"miu sangat jauh : "<<miu[1][5]<<endl;
cout<<"\n\n\n================================\n\n";
// RULE
atot[0]=0 ;
aztot[0]=0 ;
a=1;
for(b=1;b<=5;b++)
{ for(c=1;c<=5;c++)
{if (b==1) {cout<<"jika sangat lambat dan";}
else if (b==2) {cout<<"jika agak lambat dan";}
else if (b==3) {cout<<"jika sedang dan";}
else if (b==4) {cout<<"jika agak cepat dan";}
else if (b==5) {cout<<"jika sangat cepat dan";}
if (c==1) {cout<<" sangat dekat ";}
else if (c==2) {cout<<" agak dekat ";}
else if (c==3) {cout<<" sedang ";}
else if (c==4) {cout<<" agak jauh ";}
else if (c==5) {cout<<" sangat jauh ";}
u[a] = miu[0][b]< miu[1][c]? miu[0][b] : miu[1][c];
if (a==16||a==21||a==22)
{
z1[a]= ba1[2]-u[a]*(ba1[2]-batas1[2]);
z2[a]= ba1[2]-u[a]*(ba1[2]-batas1[2]);
cout<<"maka injak penuh -> Z"<<a<<" :"<<z1[a]<<" & "<<z2[a]<<endl;
}
else if (a==6||a==11||a==12||a==17||a==18||a==23||a==24)
{
z1[a]= ba1[2]+u[a]*(ba1[2]-batas1[2]);
z2[a]= ba2[2]-u[a]*(ba2[2]-ba1[2]);
cout<<"maka injak agak penuh -> Z"<<a<<" :"<<z1[a]<<" & "<<z2[a]<<endl;}
else if (a==1||a==7||a==13||a==19||a==25)
{
z1[a]= ba2[2]+u[a]*(ba2[2]-ba1[2]);
z2[a]= ba3[2]-u[a]*(ba3[2]-ba2[2]);
cout<<"maka injak sedang -> Z"<<a<<" :"<<z1[a]<<" & "<<z2[a]<<endl;}
else if (a==2||a==3||a==8||a==9||a==14||a==15||a==20)
{
z1[a]= ba3[2]+u[a]*(ba3[2]-ba2[2]);
z2[a]= ba3[2]-u[a]*(batas2[2]-ba3[2]);
cout<<"maka injak agak sedikit -> Z"<<a<<" :"<<z1[a]<<" & "<<z2[a]<<endl;}
else if (a==4||a==5||a==10)
{
z1[a]= ba3[2]+u[a]*(batas2[2]-ba3[2]);
z2[a]= ba3[2]+u[a]*(batas2[2]-ba3[2]);
cout<<"maka injak sangat sedikit -> Z"<<a<<" :"<<z1[a]<<" & "<<z2[a]<<endl;}
//peringkas hitung sudut rem
atot[a]=atot[a-1]+u[a];
az1[a]=u[a]*z1[a];
az2[a]=u[a]*z2[a];
aztot[a]=aztot[a-1]+az1[a]+az2[a];
a++;
}
}
//hasil sudut rem
s=aztot[25]/(atot[25]*2);
cout<<"\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
cout<<"\n\nsudut injak rem : "<<s<<" derajat"<<endl;;
//konf ulang?
cout<<"\n\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%"<<endl;
cout<<"ulangi lagi(Y/T)??";
cin >> konf;
if (konf=='Y' || konf=='y')
{ //reset;
for(a=0;a<=1;a++)
{ miu[a][1]=0;
miu[a][2]=0;
miu[a][3]=0;
miu[a][4]=0;
miu[a][5]=0;}
goto ulang;}
else
{getch();}
}
Artikel Terkait
0 komentar :
Posting Komentar