Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question: Welcome to the EBAC Calculator JAVA HELP Learning Objectives 1. (10 po

ID: 3906867 • Letter: Q

Question

Question: Welcome to the EBAC Calculator

JAVA HELP

Learning Objectives 1. (10 points) Create a main program that successfully compiles 2. (47 points) Program runs successfully (15 points) Input the user values using a Scanner object. a. i. Alcohol Units ii. Weight iii. Metabolic Constants iv. Alcohol Consumed v. Time Drinking b. (16 points) Output the correct EBAC calculation for all four cases (16 points) Outputs the correct category using Oklahoma law c. 3. (43 points) Program contents follow readability standards including a. (10 points) Correct use of branching Make good choices for the use of multiple if statements, if-else statements, and nested if statements i. Note: There are many good options depending on vour design, but you must never use multiple if-statements when eaclh statement is mutually exclusive. This means when the second if-statement can ONLY happen when the first if-statement is false, then that second statement should be an else (or an else- if). This makes the code more efficient and less prone to bugs 1. b. (10 points) Correct variable types with Useful, Camel-case identifiers c. (10 points) Constants for 6 Metabolic values used in the formulas with useful upper-case, underscore separated identifier (5 points) Proper Tabbing and Spacing d· Note: Use Source -> Format frequently in Eclipse ii. i. All points will be lost if the page cannot be easily read by the grader e. (8 points) Seven useful comments in the code i. Note: Use // make a comment and put it on the line BEFORE the code it explains to make it easier to see/grade Note: Only projects that adhere to the Submission Requirements (at the end of this document) will be graded. Failure to meet these requirements will result in a 0 for this project

Explanation / Answer

Given below is the code for the question.
To indent code in eclipse , select code by pressing ctrl+a and then indent using ctrl+i
Please do rate the answer if it was helpful. Thank you


import java.util.Scanner;

public class EBACCalculator {
public static void main(String[] args) {
int alcoholUnitType, weight;
double consumed, hours;
int constantType;
double EBAC;
final double BW_MALE = 0.58;
final double BW_FEMALE = 0.49;
final double ADR_MALE = 0.73;
final double ADR_FEMALE = 0.66;
final double MR_MALE = 0.015;
final double MR_FEMALE = 0.017;

double BW, ADR, MR;

Scanner keyboard = new Scanner(System.in);


System.out.println("Which type of alcohol units would you like to use?");
System.out.println("1. Standard Drink Units");
System.out.println("2. Ounces of Alcohol");
alcoholUnitType = keyboard.nextInt();

System.out.println("Which is your weight(in whole pounds)?");
weight = keyboard.nextInt();

System.out.println("Which metabolic constants do you want to use?");
System.out.println("1. male");
System.out.println("2. female");
constantType = keyboard.nextInt();

System.out.println("How much alcohol have you consumed?");
consumed = keyboard.nextDouble();

System.out.println("How long have you been drinking (in hours)?");
hours = keyboard.nextDouble();

if(constantType == 1){
BW = BW_MALE;
ADR = ADR_MALE;
MR = MR_MALE;
}
else{
BW = BW_FEMALE;
ADR = ADR_FEMALE;
MR = MR_FEMALE;
}

if(alcoholUnitType == 1){
EBAC = ((0.806 * consumed * 1.2) / (BW * weight * 0.453592)) - MR * hours;

}
else{
EBAC = ((consumed * 5.14)/(ADR * weight)) - MR * hours;
}


System.out.println("Your estimated EBAC is " + EBAC + "%");
if(EBAC >= 0.08)
System.out.println("By Oklahoma law, you would be charged with a DUI");
else if(EBAC > 0.05)
System.out.println("By Oklahoma law, you would be charged wit ha DWI if you hold a standard driver license " +
"(or a DUI if you hold a commercial license.)" );
else if(EBAC > 0.04)
System.out.println("By Oklahoma law, you would be charged with a DUI if you hold a commercial license");
else if(EBAC > 0)
System.out.println("By Oklahoma law, you are within the legal limits to drive as long as you are over 21");
else
System.out.println("You are completely sober");
}
}

output
====
Which type of alcohol units would you like to use?
1. Standard Drink Units
2. Ounces of Alcohol
2
Which is your weight(in whole pounds)?
170
Which metabolic constants do you want to use?
1. male
2. female
1
How much alcohol have you consumed?
4.2
How long have you been drinking (in hours)?
4.5
Your estimated EBAC is 0.10645648670427077%
By Oklahoma law, you would be charged with a DUI

Which type of alcohol units would you like to use?
1. Standard Drink Units
2. Ounces of Alcohol
2
Which is your weight(in whole pounds)?
115
Which metabolic constants do you want to use?
1. male
2. female
2
How much alcohol have you consumed?
2.0
How long have you been drinking (in hours)?
3.0
Your estimated EBAC is 0.08444137022397889%
By Oklahoma law, you would be charged with a DUI

Which type of alcohol units would you like to use?
1. Standard Drink Units
2. Ounces of Alcohol
1
Which is your weight(in whole pounds)?
176
Which metabolic constants do you want to use?
1. male
2. female
1
How much alcohol have you consumed?
3.0
How long have you been drinking (in hours)?
2.0
Your estimated EBAC is 0.03266593081509844%
By Oklahoma law, you are within the legal limits to drive as long as you are over 21


Which type of alcohol units would you like to use?
1. Standard Drink Units
2. Ounces of Alcohol
1
Which is your weight(in whole pounds)?
154
Which metabolic constants do you want to use?
1. male
2. female
2
How much alcohol have you consumed?
2.5
How long have you been drinking (in hours)?
2.0
Your estimated EBAC is 0.036643809276495826%
By Oklahoma law, you are within the legal limits to drive as long as you are over 21

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote