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);

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter3: Input/output
Section: Chapter Questions
Problem 4PE: 4. During each summer, John and Jessica grow vegetables in their backyard and buy seeds and...
icon
Related questions
Question

Java output caffeine levels

FAQ
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.
407614 2611836.q«Begy7|
0/10
LAB
ACTIVITY
2.19.1: LAB: Caffeine levels
Load default template...
LabProgram.java
75°F
1 import java.util.Scanner;
2
3 public class LabProgram {
4
Type here to search
public static void main(String[] args)
Et
$
0
C
Transcribed Image Text:FAQ 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. 407614 2611836.q«Begy7| 0/10 LAB ACTIVITY 2.19.1: LAB: Caffeine levels Load default template... LabProgram.java 75°F 1 import java.util.Scanner; 2 3 public class LabProgram { 4 Type here to search public static void main(String[] args) Et $ 0 C
LabProgram.java
Load default
1 import java.util.Scanner;
S
2
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.
caffeineMg = scnr.nextDouble();
/* Type your code here. */
Submit mode
Run your program as often as you'd like, before submitting for grading. Below, type ar
input values in the first box, then click Run program and observe the program's outpu
C
✡
?
75°F
21
E: G
UTION CO
6
9
10 }
11 }
12
Develop mode
search
tertentirati nategnut
ESPACELAT
Transcribed Image Text:LabProgram.java Load default 1 import java.util.Scanner; S 2 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. caffeineMg = scnr.nextDouble(); /* Type your code here. */ Submit mode Run your program as often as you'd like, before submitting for grading. Below, type ar input values in the first box, then click Run program and observe the program's outpu C ✡ ? 75°F 21 E: G UTION CO 6 9 10 } 11 } 12 Develop mode search tertentirati nategnut ESPACELAT
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage