Question: **Create a C ++ program that uses all the above functions. The main function goes to be the integrator of the functions described; that is,

**Create a C ++ program that uses all the above functions. The main function goes to be the integrator of the functions described; that is, main calls each of the other functions at the right time.

You must properly document the code and submit several executions to show that the program works well. 

1. void policeAction(double BAC) { if(BAC>=0.01 && BAC<0.05) printf("Hardly the driver is doing something illegal (but couldnot complicate other traffic infractions)"); else if(BAC >= 0.05 && BAC < 0.10) printf("The driver could be subject to arrest(at his discretion of the officer))"); else printf("The driver would have an automatic arrest with jail sentence");

2. //this is the defintion for the function

double Calculate_Alcohol_Concentration(double A, double w, int t, char sex)

{

//variable declaration

double BAC;

double r;

//if sex is F

if (sex == 'F')

{

//set r for the female

r = 0.55;

//calculate BAC

BAC = (A/(r * w)) - 0.015 * t + 0.0165;

}

//else if sex is men

else if (sex == 'N')

{

//set r for male

r = 0.55;

//calculate BAC

BAC = (A/(r * w)) - 0.015 * t + 0.0165;

}

//return BAC to main function

return BAC;

}//end of the function defintion

3. void personInfo(){ double weight; int numDrinks; double alcoholContent; int time; char sex;

// Prompt for weight while(1){ cout << "Enter the weight of the person (in pounds): "; cin >> weight; if(weight > 0.0){ cout << endl; break; } cout << "Weight must be greater than 0.0!" << endl; // warning message }

// Prompt for number of drinks while(1){ cout << "Enter the number of drinks consumed (in nb): "; cin >> numDrinks; if(numDrinks > 0){ cout << endl; break; // break loop if input is valid } cout << "Number of drinks cannot be negative!" << endl; }

// Prompt for Alcohol Content of a drink while(1){ cout << "Enter the alcohol content of a drink (in ca): "; cin >> alcoholContent; if(alcoholContent > 0){ cout << endl; break; // break loop if input is valid } cout << "Alcohol content cannot be negative!" << endl; }

// Prompt for number of time while(1){ cout << "Enter the time it took to consume beverages (in hours): "; cin >> time; cin.ignore(); if(time > 0){ cout << endl; break; // break loop if input is valid } cout << "Time cannot be negative!" << endl; }

// Prompt to enter sex while(1){ cout << "Enter sex of the person (M/F): "; cin >> sex; if(sex == 'M' || sex == 'F'){ cout << endl; break; } cout << "Only \"F\" or \"M\" are accepted!" << endl; } }

4. //this is the function defintion which calculate the amount of //alcohol consumed by a person

double Calculate_amount_of_alcohol(int nb, double ca)

{

//caculate consumed amount

double A = nb * ca;

//return amount to calling function

return A;

}//end of the function definition

5. Float convert (float lbs)

{

Float w; //w will store weigh in hactogram

W= (10/2.2046)*lbs; // calculating the value

Return (w); // return the value of w

}

6. #include // function to print given sign void printsign(void) { printf("\"Program to determine risks in case of driving after having consumed alcohol\"\."); } int main() { //calling function printsign(); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!