Blood alcohol content (BAC) is a measure of how much alcohol is in someone’s blood. It is usually measured as a percentage, so a BAC of 0.3% is three-tenths of one percent. That is, there are 3 grams of alcohol for every 1,000 grams of blood. A BAC of 0.05% impairs reasoning and the ability to concentrate. A BAC of 0.30% can lead to a blackout, shortness of breath, and loss of bladder control. In most states, the legal limit for driving is a BAC of 0.08%. BAC is usually measured by a breathalyzer, urinalysis, or blood test. However, Swedish physician E. M. P. Widmark developed the following equation for estimating an individual’s BAC. This formula is widely used by forensic scientists. B = -0.015*t+ ├ ( (2.84*N)/(W*g)┤ ) The variables in the formula are defined as: B = percentage of BAC N = number of “standard drinks” (N should be at least 1) (NOTE: A standard drink is one 12-ounce beer, one 5-ounce glass of wine, or one 1.5-ounce shot of distilled liquor.) W = weight in pounds g = gender constant, 0.68 for men and 0.55 for women t = number of hours since the first drink Write a C++ computer program that prompts your user for the elements needed to estimate Blood Alcohol Content using the Widmark formula above. The program should allow your user to continue to make Blood Alcohol Content estimates until they enter a sentinel value. Be sure to inform your user what that sentinel value is. Validate all the user input values. Use the following table to determine which of the possible effects corresponds to the BAC value that was calculated. BAC Estimate Possible Effects Less Than 0.03% Normal behavior, no impairment 0.03% or greater, but less than 0.06% Mild euphoria and impairment 0.06% or greater, but less than 0.10% Euphoric, increased impairment 0.10% or greater, but less than 0.20% Drunk, loss of motor control 0.20% or greater, but less than 0.30% Confused, possible blackout 0.30% or greater, but less than 0.40% Possibly unconscious 0.40% or greater Unconscious, risk of death Your program should display the BAC value and the possible effects that correspond to that value. The legal limit for driving is a BAC of 0.08%. If the BAC value is 0.08% or greater, your program should also display a phrase like “Over the legal limit for driving.” To receive full credit for this programming assignment, you must: Use the correct file name, “XYProjectOne”, where “X” and “Y” are your first and last initials. Submit a program that executes correctly. Interact effectively with the user in your prompts and error messages. Grading Guideline: Create a comment containing the student’s full name. (5 points) Document the program with other meaningful comments. (5 points) Prompt the user for the number of standard drinks. (5 points) Prompt the user for their weight in pounds. (5 points) Prompt the user for their gender. (10 points) Use the correct gender constant. (5 points) Prompt the user for the number of hours since the first drink. (5 points) Define and use a sentinel value correctly. (5 points) Correctly echo back all the input parameters. (10 points) Validate all the user input values. (5 points) Calculate the BAC value correctly. (10 points) Display the BAC value. (5 points) Determine and display the appropriate possible effects. (10 points) Allow user to repeatedly make BAC estimates. (5 points) Correctly add “Over the limit” when BAC is 0.08% or greater. (5 points) Use prompts and error messages that were easy to understand. (5 points)
Screenshot
------------------------------------------------------------------------
Program
//Header files for I/O and formatting
#include <iostream>
#include<iomanip>
using namespace std;
//Function prototype
void calculateBAC(int, double, int,char);
int main()
{
//Variables for input read
int numConsumed,t;
double weight;
char gender;
//Welcome message
cout << "***** Welcome To Blood Alcohol Content
Checker *****" << endl;
//Inputfor number of drinks consumed and error
check
cout << "Please enter the number of standard
drinks consumed (0 for exiting the application otherwise>=1):
";
cin >> numConsumed;
while (numConsumed < 0) {
cout << "Error!!! number of
standard drinks consumed is greater than equal to 1 or 0 for
exiting application!!" << endl;
cout << "Please enter the
number of standard drinks consumed (0 for exiting the application
otherwise>=1): ";
cin >> numConsumed;
}
//Loop until sentinal
while (numConsumed!=0) {
//Prompt for weight and error
check
cout << "Enter the weight in
pounds: ";
cin >> weight;
while (weight <= 30) {
cout <<
"Error!!!Weight should not be less than 30!!" << endl;
cout <<
"Enter the weight in pounds: ";
cin >>
weight;
}
//Prompt for hours first drink used
and error check
cout << "The number of hours
since the first drink : ";
cin >> t;
while (t << 0 && t
> 24) {
cout <<
"Error!!!!Hours should not be negative or greater than 1 day!!!"
<< endl;
cout <<
"The number of hours since the first drink : ";
cin >>
t;
}
//Prompt for gender and error
check
cout << "Are you
male/female(m/f): ";
cin >> gender;
gender = toupper(gender);
while (gender != 'M' &&
gender != 'F') {
cout <<
"Error!!!Gender should be m/f" << endl;
cout <<
"Are you male/female(m/f): ";
cin >>
gender;
gender =
toupper(gender);
}
//Function to calculate BAC
calculateBAC(numConsumed, weight,
t, gender);
cout << endl;
//Repetition
cout << "Please enter the
number of standard drinks consumed (0 for exiting the application
otherwise>=1): ";
cin >> numConsumed;
while (numConsumed<0) {
cout <<
"Error!!! number of standard drinks consumed is greater than equal
to 1 or 0 for exiting application!!" << endl;
cout <<
"Please enter the number of standard drinks consumed (0 for exiting
the application otherwise>=1): ";
cin >>
numConsumed;
}
}
}
/*
Function to calculate BAC
Generate appropriate message
*/
void calculateBAC(int N, double W, int t, char g) {
cout << setprecision(3);
double B;
if (g == 'M') {
B = -0.015*t + abs(((2.84*N) /
(W*.68)));
}
else{
B = -0.015*t + abs(((2.84*N) /
(W*.55)));
}
cout << "Your BAC level = " << B <<
endl;
cout << "Possible effects at this level : -
";
if (B < 0.03) {
cout << "Normal behavior, no
impairment" << endl;
}
else if (B >= 0.03 && B<0.06) {
cout << "Mild euphoria and
impairment" << endl;
}
else if (B >= 0.06 && B < 0.10) {
cout << "Euphoric, increased
impairment" << endl;
}
else if (B >= 0.10 && B < 0.20) {
cout << "Drunk, loss of motor
control" << endl;
}
else if (B >= 0.20 && B < 0.30) {
cout << "Confused, possible
blackout" << endl;
}
else if (B >= 0.30 && B < 0.40) {
cout << "Possibly
unconscious" << endl;
}
else{
cout << "Unconscious, risk of
death" << endl;
}
if (B >= 0.08) {
cout << "This BAC level Over
the legal limit for driving." << endl;
}
}
----------------------------------------------------------------------------------
Output
***** Welcome To Blood Alcohol Content Checker *****
Please enter the number of standard drinks consumed (0 for exiting
the application otherwise>=1): 1
Enter the weight in pounds: 55
The number of hours since the first drink : 1
Are you male/female(m/f): m
Your BAC level = 0.0609
Possible effects at this level : - Euphoric, increased
impairment
Please enter the number of standard drinks consumed (0 for exiting the application otherwise>=1):0
Blood alcohol content (BAC) is a measure of how much alcohol is in someone’s blood. It...
Create a PHP script that will calculate a person's Blood Alcohol Content (BAC). This program will ask the user for the following variables: • $weight • $gender ... if male, then $ratio = 0.73; if female, then $ratio = 0.66 • $number_of_drinks • $amount_of_alcohol (in ounces) of the drinks consumed (for example, American Beer typically has between 4-6% Alcohol content) • $hours since your last drink The formula to calculate the Blood Alcohol Content (BAC) is as follows: $BAC =...
Which of the following is NOT a true statement regarding blood alcohol content (BAC)? In most individuals, the maximum rate of alcohol metabolism is one ounce per hour. A woman weighing 130 pounds easily exceeds the legal limit after consuming the equivalent of one alcoholic drink. Food in the stomach will slow the rise in BAC. A BAC of 0.08% is the legal limit for intoxication in the United States. Moderate drinking can provide all of the following benefits EXCEPT:...
The legal blood alcohol level is .08%. Blood alcohol level largely depends on an individual’s BMI and the percentage and amount of whatever it is they consumed. Create a program that could potentially help users estimate how long to wait before driving, if they must drive. Program Description This program will will allow user to create an account. The program will also save the users name, weight, age, and height. It will give the user the option of adding an...
How much alcohol can one consume before one's Blood Alcohol Content (BAC) is above the legal limit? An experiment was conducted at Gallaudet University to predict Blood Alcohol Content from the number of beers. A total of 50 volunteer college students (some men and some women) were assigned a certain number of beers to drink and then, after a half an hour, their Blood Alcohol (BAC) level was measured. To make this assignment simpler, we will only use the first...
How much alcohol can one consume before one's Blood Alcohol Content (BAC) is above the legal limit? An experiment was conducted at Gallaudet University to predict Blood Alcohol Content from the number of beers. A total of 50 volunteer college students (some men and some women) were assigned a certain number of beers to drink and then, after a half an hour, their Blood Alcohol (BAC) level was measured. To make this assignment simpler, we will only use the first...
This should be in Python Statement : A lot of people drink and drive. The legal blood alcohol level is .08%. Blood alcohol level largely depends on an individual’s BMI and the percentage and amount of whatever it is they consumed. This program could potentially help users estimate how long to wait before driving, if they must drive. Program Description This program will: Give the most recent statistics of drinking and driving in California. It will allow user to create...
This should be in Python Statement : A lot of people drink and drive. The legal blood alcohol level is .08%. Blood alcohol level largely depends on an individual’s BMI and the percentage and amount of whatever it is they consumed. This program could potentially help users estimate how long to wait before driving, if they must drive. Program Description This program will: Give the most recent statistics of drinking and driving in California. It will allow user to create...
I need to test a hypothesis regarding drunk driving: i.e., that a higher blood alcohol content of 0.08+ causes a higher rate of drunk driving fatalities, than a lower blood alcohol content of 0.01-0.07. This is to prove that the American BAC level should be lowered from 0.08 to a range of 0.01-0.07 to reduce drunk driving fatalities. I chose a random sample of 10 U.S. states: 1) Total Fatalities for 2016 and 2015, 2) Total fatalities with a driver’s...
Question 1 At what BAC does a person experience impairment of balance, speech, vision, reaction time, and hearing? Not yet answered Select one: .25 BAC .15 BAC .08 BAC .06 BAC Question 2 Which of the following is true about drinking and age? Not yet answered Select one: It doesn't matter how young you are when you start drinking People who start drinking younger are more likely to become dependent on alcohol People who start drinking younger learn how to...
BrAC BAC 0.7 0.5 1.13 0.22 0.82 Question 2. Prevention and detection of drinking and driving are major concerns of traffic Driver police. In the U.S. in 2012, nearly one-third of all traffic deaths involved 0.34 drivers with excessive blood alcohol concentrations (BAC). Investigative 0.26 authorities employ breath-alcohol analyzers, i.e. breathalyzers, to measure breath alcohol concentrations (BrAC) because the tests can be easily applied and do not require an attending physician to extract blood. Thresholds for 0.29 alcohol-impaired driving are...