- Joined
- Jun 28, 2012
- Messages
- 150
- Reaction score
- 14
Can someone point out what's the problem with my 2 logic.
Feel free to add / remove any variables. Please help me
Problem:
Logic 1:
Logic 2: Unfinish , don't have any "charge"
Feel free to add / remove any variables. Please help me
Problem:
Logic 1:
Code:
#include<iostream.h>
#include<conio.h>
int main()
{ // start main
int T,D,F,P,C,M,N,S,E,CX,JX,PX,TX,VX,BX,KX;
char destine,code;
double vat,vatable,charge;
cout<<"Welcome to SLEX!\n";
cout<<"Please enter the type of your vehicle:\n BX for Buses, KX for Trucks \n CX for Car, JX for Jeep \n PX for pick Ups, TX for Taxi \n VX for Vans:";
cin>>code;
if(code==BX)
{ //else if in code BX for Buses
cout<<"Enter your destination:";
cin>>destine;
if(destine==T)charge=543;
else if(destine==D)charge=472;
else if(destine==F)charge=360;
else if(destine==P)charge=278;
else if(destine==C)charge=218;
else if(destine==M)charge=208;
else if(destine==N)charge=183;
else if(destine==S)charge=174;
else if(destine==E)charge=113;
else
{ // start of error handling
cout<<"Your destination code is not in the list!\n";
getch();
exit(1);
} //end of error handling
} // end of code B
else if(code==KX)
{ // start of code K for Trucks
cout<<"Enter your destination:\n";
cin>>destine;
if(destine==T)charge=543;
else if(destine==D)charge=472;
else if(destine==F)charge=360;
else if(destine==P)charge=278;
else if(destine==C)charge=218;
else if(destine==M)charge=208;
else if(destine==N)charge=183;
else if(destine==S)charge=174;
else if(destine==E)charge=113;
else
{ //start if error handling
cout<<"Your destination code is not in the list!\n";
getch();
exit(1);
} //end of error handling
} // end of code K
else if(code==CX)
{ // start of Code C
cout<<"Enter your destination:\n";
cin>>destine;
if(destine==T)charge=272;
else if(destine==D)charge=236;
else if(destine==F)charge=180;
else if(destine==P)charge=140;
else if(destine==C)charge=108;
else if(destine==M)charge=104;
else if(destine==N)charge=91;
else if(destine==S)charge=87;
else if(destine==E)charge=56;
else
{ // start of error handling
cout<<"Your destination code is not in the list!\n";
getch();
exit(1);
} // end of error handling
}// end if code C
else if(code==JX)
{ // start of Code J
cout<<"Enter your destination:\n";
cin>>destine;
if(destine==T)charge=272;
else if(destine==D)charge=236;
else if(destine==F)charge=180;
else if(destine==P)charge=140;
else if(destine==C)charge=108;
else if(destine==M)charge=104;
else if(destine==N)charge=91;
else if(destine==S)charge=87;
else if(destine==E)charge=56;
else
{ // start of error handling
cout<<"Your destination code is not in the list!\n";
getch();
exit(1);
} // end of error handling
}// end if code J
else if(code==PX)
{ // start of Code P
cout<<"Enter your destination:\n";
cin>>destine;
if(destine==T)charge=272;
else if(destine==D)charge=236;
else if(destine==F)charge=180;
else if(destine==P)charge=140;
else if(destine==C)charge=108;
else if(destine==M)charge=104;
else if(destine==N)charge=91;
else if(destine==S)charge=87;
else if(destine==E)charge=56;
else
{ // start of error handling
cout<<"Your destination code is not in the list!\n";
getch();
exit(1);
} // end of error handling
}// end if code P
else if(code==TX)
{ // start of Code TX
cout<<"Enter your destination:\n";
cin>>destine;
if(destine==T)charge=272;
else if(destine==D)charge=236;
else if(destine==F)charge=180;
else if(destine==P)charge=140;
else if(destine==C)charge=108;
else if(destine==M)charge=104;
else if(destine==N)charge=91;
else if(destine==S)charge=87;
else if(destine==E)charge=56;
else
{ // start of error handling
cout<<"Your destination code is not in the list!\n";
getch();
exit(1);
} // end of error handling
}// end if code TX
else if(code==VX)
{ // start of Code VX
cout<<"Enter your destination:\n";
cin>>destine;
if(destine==T)charge=272;
else if(destine==D)charge=236;
else if(destine==F)charge=180;
else if(destine==P)charge=140;
else if(destine==C)charge=108;
else if(destine==M)charge=104;
else if(destine==N)charge=91;
else if(destine==S)charge=87;
else if(destine==E)charge=56;
else
{ // start of error handling
cout<<"Your destination code is not in the list!\n";
getch();
exit(1);
} // end of error handling
}// end if code VX
vat = charge * 0.12;
vatable = charge - vat;
cout<<"==========SUMMARY==========\n";
cout<<"Type of vehicle:\n"<<code<<endl;
cout<<"Destination:\n"<<destine<<endl;
cout<<"Charges:\n"<<charge<<endl;
cout<<"VAT(12%):\n"<<vat<<endl;
cout<<"VATable charges:\n"<<vatable<<endl;
cout<<"HAVE A SAFE TRAVEL!!!\n";
getch();
return 0;
} // end main
Logic 2: Unfinish , don't have any "charge"
Code:
#include<iostream.h>
#include<conio.h>
int main()
{
int T,D,F,P,C,M,N,S,E,c,j,p,t,v,b,k;
double vat,vata,charge;
char code,des;
cout<<" Welcome to SLEX \n";
cout<<" Enter the type of Vehicle:";
cin>>code;
if((code=='C')||(code=='c'))
{
T=272;
D=236;
F=180;
P=140;
C=108;
M=104;
N=91;
S=87;
E=56;
}
else if((code=='J')||(code=='j'))
{
T=272;
D=236;
F=180;
P=140;
C=108;
M=104;
N=91;
S=87;
E=56;
}
else if((code=='P')||(code=='p'))
{
T=272;
D=236;
F=180;
P=140;
C=108;
M=104;
N=91;
S=87;
E=56;
}
else if((code=='T')||(code=='t'))
{
T=272;
D=236;
F=180;
P=140;
C=108;
M=104;
N=91;
S=87;
E=56;
}
else if((code=='V')||(code=='v'))
{
T=272;
D=236;
F=180;
P=140;
C=108;
M=104;
N=91;
S=87;
E=56;
}
else if((code=='B')||(code=='b'))
{
T=543;
D=472;
F=360;
P=278;
C=218;
M=208;
N=183;
S=173;
E=113;
}
else if((code=='K')||(code=='k'))
{
T=543;
D=472;
F=360;
P=278;
C=218;
M=208;
N=183;
S=173;
E=113;
}
else
{
cout<<"Code invalid, Program terminates!\n";
getch();
exit(1);
}
cout<<"Enter your destination, PLEASE USE CAPITAL LETTER!:";
cin>>des;
if((des==T)||(des==t))
{
cout<<"Tipo\n";
}
else if(des==D)
{
cout<<"Dinalupihan\n";
}
else if(des==F)
{
cout<<"FloridaBlanca\n";
}
else if(des==P)
{
cout<<"Porac\n";
}
else if(des==C)
{
cout<<"Clark South\n";
}
else if(des==M)
{
cout<<"Mabalacat\n";
}
else if(des==N)
{
cout<<"Clark North\n";
}
else if(des==S)
{
cout<<"Dolores\n";
}
else if(des==E)
{
cout<<"Concepcion\n";
}
else
{
cout<<"Invalid code, program terminates...\n";
getch();
exit(1);
}
cout<<"your total charge is"<<code;
}

