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

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,...
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...
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...
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...
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.
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...
***Please answer the question using the JAVA programming language. Write a program that calculates mileage reimbursement...
***Please answer the question using the JAVA programming language. Write a program that calculates mileage reimbursement for a salesperson at a rate of $0.35 per mile. Your program should interact (ask the user to enter the data) with the user in this manner: MILEAGE REIMBURSEMENT CALCULATOR Enter beginning odometer reading > 13505.2 Enter ending odometer reading > 13810.6 You traveled 305.4 miles. At $0.35 per mile, your reimbursement is $106.89. ** Extra credit 6 points: Format the answer (2 points),...
Create a program in java that calculates area and perimeter of a square - use a...
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.
Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT