fucntions

i need to edit this code so that my main look something like this

void telluser();
int DetermineSpeed();
bool DetermineDrunk();
void DetermineFine(int Speed, bool Drunk);
Int main()
{
int Speed;
bool Drunk;
TellUser();
Speed = DetermineSpeed();
Drunk = DetermineDrunk();
DetermineFine( Speed, Drunk);
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  

#include <iostream>
#include <stdlib.h>

using namespace 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!!";
     }
     
   	else if((speed > 60 && speed < 65) && (drunk=='Y'||drunk == 'y' ))
	{
		cout<<"warning!! Go take a shower";
	}
	else if((speed==65 && speed<=70) && (drunk=='N'||drunk == 'n'))
	{
		cout<<"$5 fine for km/hr over 60km/hr ";
	}

	else if  ((speed==65 && speed<=70) && (drunk=='Y'||drunk == 'y'))
	{
		cout<<"$7 FINE!!for each km/hr over 60km/hr! Go take a shower";
	}
    else if((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.

More info:
http://cplusplus.com/doc/tutorial/functions/
http://cplusplus.com/doc/tutorial/functions2/

HTH,
Aceix.
THANKS VERY MUCH ACEIX.. ILL TRY WORK ON IT.
Topic archived. No new replies allowed.