Question

In: Computer Science

Write a Java program that calculates the blood alcohol content of someone drinking Jagerbombs. Assume that...

Write a Java program that calculates the blood alcohol content of someone drinking Jagerbombs. Assume that there are 0.55 ounces of alcohol in one Jagerbomb. Pick values of your own choosing for the number of drinks and the weight. Also output whether or not the person would be legally intoxicated in your state.

The following formula gives a rough estimate of your blood alcohol content (BAC) and is derived from formulas posted by the National Highway Traffic safety administration:

BAC = (4.136 x numDrinks x ouncesAlcohol) / (weight)

numDrinks is the number of drinks ingested.

ouncesAlcohol is the number of ounces of alcohol per drink

weight is the weight of the drinker in pounds

Note: that this formula gives only a rough estimate and doesn’t include your metabolism, time spent drinking, gender differences, etc.

Solutions

Expert Solution

SOURCE CODE:

import java.util.*;
import java.lang.*;
import java.io.*;

class BAC
{
public static void main (String[] args) throws java.lang.Exception
{

Scanner input=new Scanner(System.in);

int numDrinks;
double weight;

System.out.println("Enter the number of DRINKS: ");
numDrinks=input.nextInt(); //taking input from user the number of drinks..

System.out.println("Enter your WEIGHT in pounds: ");
weight=input.nextDouble(); //taking input from user the weight in pounds..

double BAC= (4.136*numDrinks*0.55)/weight; //calculating BAC as per the formula given in the question..

System.out.println("Blood alcohol content is: "+BAC); //printing the values of BAC..

//In our state we have taken BAC<=0.16 as legally intoxic person..

if(BAC<=0.16) //you can change the legal value of BAC according to your state..
{
System.out.println("The person is legally intoxicated.");
}

else
{
System.out.println("The person is not legally intoxicated.");
}
}
}

OUTPUT:

NOTE: I have taken the legal value BCA as less than or equal to 0.12. You can take its legal value as per your state and as class name was not given I have taken it myself i.e. "BCA"

I have mentioned comments in the code wherever necessary. Please copy entire code and save it with "BCA.java" then compile and run.

HOPE IT HELPS..!!!!

For any query please feel free to comment..

Thanks.


Related Solutions

Beer and Blood Alcohol Content The relationship between number of beers consumed (x) and blood alcohol...
Beer and Blood Alcohol Content The relationship between number of beers consumed (x) and blood alcohol content ( y) was studied in 25 male college students by using simple linear regression. The estimated blood alcohol content ( ŷ ) is given in the following regression equation: ŷ = -0.0127 + 0.0180x Suppose that the legal blood alcohol content limit for driving is 0.05. If John consumed 4 beers the model would predict that he would be: Select one: a. 0.0027...
IN JAVA Write a program that calculates the occupancy rate for each floor of a hotel....
IN JAVA Write a program that calculates the occupancy rate for each floor of a hotel. (Use a sentinel value and please point out the sentinel in bold.) The program should start by asking for the number of floors in the hotel. A loop should then iterate once for each floor. During each iteration, the loop should ask the user for the number of rooms on the floor and the number of them that are occupied. After all the iterations,...
Write a java program that calculates a speeding fine. The user is prompted for the speed...
Write a java program that calculates a speeding fine. The user is prompted for the speed of the vehicle, the posted speed limit and if the offence took place in the construction zone. The fine is calculated at $75 + 3$/ km over the speed limit for the first 20km over + $6 / km for the next 20 and $9/km after that. If the posted limit is 40km, the fine is doubled. If the offence took place in a...
Write a Java program that calculates a random number 1 through 100. The program then asks...
Write a Java program that calculates a random number 1 through 100. The program then asks the user to guess the number.If the user guesses too high or too low then the program should output "too high" or "too low" accordingly.The program must let the user continue to guess until the user correctly guesses the number. ★Modify the program to output how many guesses it took the user to correctly guess the right number
Write a program in java processing. Write a program that does the following: · Assume the...
Write a program in java processing. Write a program that does the following: · Assume the canvas size of 500X500. · The program asks the user to enter a 3 digit number. · The program then checks the value of the first and last digit of the number. · If the first and last digits are even, it makes the background green and displays the three digit number at the mouse pointer. · If the two digits are odd, it...
Someone calculates that the mineral content and physiological properties of the human body have a net...
Someone calculates that the mineral content and physiological properties of the human body have a net worth of about $2.65. Many estimates, however, have been calculated to appraise the real value of human life with one unanimous decision. Every human being is priceless. No monetary value can adequately replace us. No amount of money can compensate for the capabilities of the mind, body, and spirit. This fact alone would make you think that each individual has a lot going in...
Question 2: Write a java program that calculates the weighted average of three grades using the...
Question 2: Write a java program that calculates the weighted average of three grades using the method with header public static double CalculateWeightedAverage (double grade1, double grade2, double grade3), such that: [4 Marks] Weighted average = grade1 * 0.5 + grade2 * 0.25 + grade3 * 0.25 The program in the main method will: o ask the user to enter the three grades o and then call the method that will calculate the weighted average o and finally display the...
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for...
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for the check amount, then ask the user what type of tipp they would like to leave: the choices are 1 for good tip (20%), 2 for an average tip (15%), or 3 for poor tip (10%). Use their input and an if-else to calculate the tip amount. Then calculate and output the final bill: check+tip print out the bill, exactly as shown (print the...
Write a program in java which calculates the total price of an item you purchased which...
Write a program in java which calculates the total price of an item you purchased which includes sales tax. Create a Scanner object to read information from keyboard, Display prompts and get input, perform the calculation and display the Result of the program.
In java. Prefer Bluej Create a program in java that calculates area and perimeter of a...
In java. Prefer Bluej Create a program in java that calculates area and perimeter of a square - use a class and test program to calculate the area and perimeter; assume length of square is 7 ft.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT