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: %.2f mg\n", yourValue); Ex: If the input is: 100
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
In JAVA
ASSIGNMENT DESCRIPTION:
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: %.2f mg\n", yourValue);
Ex: If the input is:
100
the output is:
After 6 hours: 50.00 mg After 12 hours: 25.00 mg After 24 hours: 6.25 mg
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.
THE CODE I HAVE SO FAR:
import java.util.Scanner;
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.
caffeineMg = scnr.nextDouble();
System.out.printf("After 6 hours: %.2f mg\n", yourValue);
}
}

Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 4 images









