Question: 2 . 8 LAB: Caffeine levels LAB ACTIVITY 2 . 8 . 1 : LAB: Caffeine levels 0 1 0 A half - life is

2.8 LAB: Caffeine levels
LAB
ACTIVITY
2.8.1: LAB: Caffeine levels
010
A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-life of about 6 hours
in humans. Given caffeine amount (in mg ) as input, output the caffeine level after 6,12, and 24 hours.
Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
System.out.printf("After 6 hours: 8.2f mg
", yourValue);
Ex: If the input is:
the output is:
After 6 hours: 50.00mg
After 12 hours: 25.00mg
After 24 hours: 6.25mg
Note: A cup of coffee has about 100 mg . A soda has about 40 mg . An "energy" drink (a misnomer) has between 100 mg and 200 mg .
LabProgram.java
1 import java.util. Scanner;
3 public class LabProgram {
public static void main(String[] args){
Scanner scnr = new Scanner(System. in);
double caffeineMg; // "double" supports floating-point like 75.5, versus int for integers like 75.
2 . 8 LAB: Caffeine levels LAB ACTIVITY 2 . 8 . 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!