Question

Create a PHP script that will calculate a person's Blood Alcohol Content (BAC). This program will...

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 = ($amount_of_alcohol * 5.14 / $weight * $ratio) - .015 * $hours Compare the final result to 0.08 (the legal BAC limit) ... if the number is greater than 0.08, display a message saying that the person cannot drive, as they are above the legal limit

0 0
Add a comment Improve this question Transcribed image text
Answer #1

<html>

<body>

<form method="post">

Enter weight:

<input type="number" name="weight" /><br><br>

Enter gender:

<input type="text" name="gender" /><br><br>

Enter amount of alcohol:

<input type="number" name="amount_of_alcohol" /><br><br>

Enter hours since last drink:

<input type="number" name="hours" /><br><br>

<input type="submit" name="submit" value="Add">

</form>

<?php

   if(isset($_POST['submit']))

{

   @$weight=$_GET['weight'];   

@$gender=$_GET['gender'];

@$number_of_drinks=$_GET['number_of_drinks'];

@$amount_of_alcohol =$_GET['amount_of_alcohol '];

if($gender=="M")

{

$ratio=0.73;   

}

else

{

$ratio=0.66;

}

$BAC=($amount_of_alcohol * 5.14 / $weight * $ratio) - .015 * $hours;

if($BAC>="0.08")

{

echo "YOU cannot drive, as you are above the legal limit";

}

}

?>

</body>

</html>

Hi, since I lacked the Xampp server in my PC due to some reasons,I could not test the code. This was the best solution compiled by me. Please do give a thumbs up.

Add a comment
Know the answer?
Add Answer to:
Create a PHP script that will calculate a person's Blood Alcohol Content (BAC). This program will...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Recall that the Blood Alcohol Concentration (BAC) is calculated using Widmark's Basic Formula: A0...

    Recall that the Blood Alcohol Concentration (BAC) is calculated using Widmark's Basic Formula: A0.015H Wr where A is the total number of liquid ounces of alcohol consumed by the person since the commencement of drinking. W is the weight of the person in pounds. r is in the "alcohol distribution ratio", which for men is 0.73 and for women is 0.66 H is the period in hours during which alcohol was eliminated from the bloodstream. This is usually taken to...

  • Which of the following is NOT a true statement regarding blood alcohol content (BAC)? In most...

    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...

    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 fr...

    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...

  • Exercise 2. [Data analysis, requires R] For this questions use the bac data set from the...

    Exercise 2. [Data analysis, requires R] For this questions use the bac data set from the openintro library. To access this data set first install the package using install.packages ("openintro") (this only needs to be done once). Then load the pack- age into R with the command library(openintro). You can read about this data set in the help menu by entering the command ?openintro or help(openintro). Many people believe that gender, weight, drinking habits, and many other factors are much...

  • How much alcohol can one consume before one's Blood Alcohol Content (BAC) is above the legal...

    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...

  • The BAC is usually expressed as a percent based on weight/volume. This means that the BAC...

    The BAC is usually expressed as a percent based on weight/volume. This means that the BAC is the grams (g) of alcohol present per 100 mL of blood. For example, a BAC of 0.12% is equivalent to 0.12 g alcohol per 100 mL of blood. At 0.12%, most people are intoxicated! Typically 100 mL is referred to as 1 deciliter or 1 dL. So, 0.12% is also equivalent to 0.12 g/dL. The BAC can be calculated based on how much...

  • This should be in Python Statement : A lot of people drink and drive. The legal blood alcohol lev...

    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 lev...

    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...

  • Question 1 At what BAC does a person experience impairment of balance, speech, vision, reaction time,...

    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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT