Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please make sure your answer meets all the requirements below. Thank you! Project One, Blood Alcohol Content [C++] Blood alcohol content (BAC) is a measure
Please make sure your answer meets all the requirements below. Thank you!
Project One, Blood Alcohol Content [C++] 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. W * g (2.84 * N B = -0.015 *t + B = -0.015*t+ 2.84*NW*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, "XY ProjectOne", 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. bender Female Blood Alcohol Content Estimate using Widmark Equation Gender Weight in Number of Hours since Blood Alcohol constant pounds Standard Drinks first drink Content 0.044 0.55 140 0.081 0.118 0.063 0.68 180 0.086 0.109 NMD Male 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) 1. Do a Top-Down analysis and divide your program into components. The classic Input-Process-Output analysis is not a bad place to start. You might even consider isolating the calculation using the Widmark formula as a function. 2. Use specific prompts. If you want the user's weight in pounds, ask them for their weight in pounds. Be specific. 3. Does your user know what a "Standard Drink is? Why not tell them before asking them how many they drank. 4. If your calculations require the number of hours since the first drink, ask your user for the number of hours since the first drink. Be explicit. 5. Get your program to work correctly without the required loop that allows your user to repeatedly estimate Blood Alcohol Content. Add the loop later. 6. Use comment statements to identify what you want to do in the order you want to do those things. Then, come back one piece at a time filling in the Python code that will accomplish what your comment implied. 7. For example, insert a comment that identifies the need to validate user input after each place in your program where you accept input from your user. Then, come back and add the code to validate all the user input values after the program works correctly. 8. Use your knowledge of the hierarchy of operations to evaluate the Widmark formula correctly. Be careful. 9. Display the Blood Alcohol Content estimate using three (3) decimal places. For example, display 0.081 instead of just 0.08. 10. Validate your program's output with some know parameters. Project One, Blood Alcohol Content [C++] 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. W * g (2.84 * N B = -0.015 *t + B = -0.015*t+ 2.84*NW*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, "XY ProjectOne", 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. bender Female Blood Alcohol Content Estimate using Widmark Equation Gender Weight in Number of Hours since Blood Alcohol constant pounds Standard Drinks first drink Content 0.044 0.55 140 0.081 0.118 0.063 0.68 180 0.086 0.109 NMD Male 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) 1. Do a Top-Down analysis and divide your program into components. The classic Input-Process-Output analysis is not a bad place to start. You might even consider isolating the calculation using the Widmark formula as a function. 2. Use specific prompts. If you want the user's weight in pounds, ask them for their weight in pounds. Be specific. 3. Does your user know what a "Standard Drink is? Why not tell them before asking them how many they drank. 4. If your calculations require the number of hours since the first drink, ask your user for the number of hours since the first drink. Be explicit. 5. Get your program to work correctly without the required loop that allows your user to repeatedly estimate Blood Alcohol Content. Add the loop later. 6. Use comment statements to identify what you want to do in the order you want to do those things. Then, come back one piece at a time filling in the Python code that will accomplish what your comment implied. 7. For example, insert a comment that identifies the need to validate user input after each place in your program where you accept input from your user. Then, come back and add the code to validate all the user input values after the program works correctly. 8. Use your knowledge of the hierarchy of operations to evaluate the Widmark formula correctly. Be careful. 9. Display the Blood Alcohol Content estimate using three (3) decimal places. For example, display 0.081 instead of just 0.08. 10. Validate your program's output with some know parametersStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started