#include <iostream>
#include <stdlib.h>
usingnamespace std;
void telluser();//prototype
int main(){
//variables
float speed;
char drunk;
cout<<"\tTRAFIC DETECTOR\n.";
cout<<"\t***************\n";
//conditions..
if((speed>60 && speed < 65) && (drunk == 'N'||drunk == 'n'))
{
cout<<" WARNING!!";
}
elseif((speed > 60 && speed < 65) && (drunk=='Y'||drunk == 'y' ))
{
cout<<"warning!! Go take a shower";
}
elseif((speed==65 && speed<=70) && (drunk=='N'||drunk == 'n'))
{
cout<<"$5 fine for km/hr over 60km/hr ";
}
elseif ((speed==65 && speed<=70) && (drunk=='Y'||drunk == 'y'))
{
cout<<"$7 FINE!!for each km/hr over 60km/hr! Go take a shower";
}
elseif((speed > 70) && (drunk=='N'||drunk == 'n'))
{
cout<<"$5 fine for each km/hr over 60km/hr up to and including";
cout<<"70km/hr\n";
cout<<"$10 fine for each km/hr over 70km/hr ";
}
else
{
cout<<"$7 fine for each km/hr over 60km/hr up to including 70km/hr,\n";
cout<<"$15 fine for each km/hr over 70km/hr,Spend the day/night in cell\n";
cout<<"untill become sober";
}
cout<<"\n\n";
//system ("PAUSE");
//return 0;
}
/* fuctoin promt user for inputs*/
void telluser()
{
int speed;
string drunk;
cout<<"Enter speed : ";
cin>>speed;
cout<<"\n\n";
cout<<"Driver drunk not : ";
cin>> drunk;
cout<<"\n\n";
}
Then put the right if statements in a function, change some variable types(eg: Drunk to bool), create the necessary functions with the right parameters and ...ummm... that's it.