-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.js
32 lines (24 loc) · 900 Bytes
/
code.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
$(document).ready(function ()
{
$("button").on("click",calculation);
})
function calculation()
{
//Get Information from the user//
let numBeers = parseInt( $("#numBeers").val() );
let numWine = parseInt( $("#numWine").val() );
let numShots = parseInt( $("#numShots").val() );
let weight = parseInt( $("#weight").val() );
let hours = parseInt( $("#hoursSinceFirstDrink").val() );
//Calculate number of liquid ounces of alcohol//
let beerOunces = numBeers * 0.54;
let wineOunces = numWine * 0.6;
let shotOunces = numShots * 0.6;
let totalOunces = beerOunces + wineOunces + shotOunces;
// Calculate the users Blood Alcohol Content//
let absorptionRate = totalOunces * 7.5;
let calculateHours = hours * 0.015;
let BAC = (absorptionRate / weight) - calculateHours;
//Print out the result//
$("span#BAC").text(BAC.toFixed(3));
}