1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
stiv31 [10]
3 years ago
12

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-lif

e of about 6 hours in humans. Given caffeine amount (in mg) as input, output the caffeine level after 6, 12, and 18 hours. Use a string formatting expression with conversion specifiers to output the caffeine amount as floating-point numbers.Ex: If the input is 100, the output is:After 6 hours: 50.000000 mgAfter 12 hours: 25.000000 mgAfter 18 hours: 12.500000 mgNote: 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.
Computers and Technology
1 answer:
Elena L [17]3 years ago
8 0

Answer:

// here is code in java.

import java.util.*;

class Solution

{

// main method of class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // declare variable

         double caffeine;

    // scanner object to read input from user

       Scanner scr=new Scanner(System.in);

       System.out.print("Enter the initial amount of caffeine:");

        // read the initial amount of caffeine

           caffeine=scr.nextDouble();

          // calculate amount of caffeine after 6,12,18 hours

          for(int i=1;i<=3;i++)

          {

               System.out.println("After "+ i*6+" hours:"+(caffeine/2)+" mg");

               // update the caffeine after every 6 hours

               caffeine=caffeine/2;

          }

                 

   }catch(Exception ex){

       return;}

}

}

Explanation:

Create a variable "caffeine" to store the initial amount of caffeine given by user. Run a loop for three time, it will calculate the amount of caffeine left after every 6 hours.First it will give the amount of caffeine left after 6 hours, then caffeine left after 12 hours and in last caffeine after 18 hours.

Output:

Enter the initial amount of caffeine:100

After6 hours:50.0 mg

After12 hours:25.0 mg

After18 hours:12.5 mg

You might be interested in
Which one of the following features can control left and right indents on using markers
QveST [7]
The Feature that can control left and right indents on using markers is Ruler.  The indent marker consists of two triangles and a rectangle.  <span>To change the left indent, click on the very bottom of the indent marker, the rectangle, and drag it to a new position.</span>  <span>The Right Indent is indicated by a single triangle on the Ruler at the current right margin. Click and drag it to change the margin.</span>
3 0
3 years ago
What is sum after the following loop terminates? int sum = 0; int item = 0; do { item ; sum = item; if (sum &gt; 4) break; } whi
irinina [24]
Int sum = 0;
int item = 0;
do
{
    item;
    sum = item;
    if (sum > 4)
        break;
} while (item < 5);


You will generate a compile error, as having (item;) as a statement on its own is invalid.
8 0
3 years ago
Read 2 more answers
Jack was drinking a glass of water near his computer when his dog bumped his arm, spilling water on his keyboard. What is the fi
Anvisha [2.4K]

Answer:

4no. is the answer may be

3 0
2 years ago
Read 2 more answers
Your program has a two-dimensional array, scores. You are implementing your array with lists. Each member in the array is a pair
Viefleur [7K]

Answer:

scores.append(6,2)

Explanation:

This is a complicated question because in theory, scores.insert can also add values, but I am sure that the only line of code that would work is scores.append(6,2)

7 0
2 years ago
What purpose would tracking changes be most useful for?
olya-2409 [2.1K]
So, you can be able to make a prediction and understand the cycle.
6 0
3 years ago
Other questions:
  • For any element in keysList with a value greater than 50, print the corresponding value in itemsList, followed by a space. Ex: I
    8·1 answer
  • The equipment that processes data in order to create information is called the _______.
    8·2 answers
  • Which of the following typically have the highest auto insurance premiums?
    14·1 answer
  • Hen using presentation software, what do you do when you "compose a slide"?
    5·1 answer
  • The device used to connect a network to the internet is called a
    7·1 answer
  • 50 POINTS &amp; A FOLLOW!
    11·2 answers
  • A musical time measurer is a(an)
    10·1 answer
  • How can i change my age on my profile here bc i am 13 but i accidenlty put 2005 instead of 2006 no need to rush to answer just w
    9·2 answers
  • Write the header file Stadium.h for a Stadium class. The Stadium class has the following data members: 1) an array of 1000 Seat
    7·1 answer
  • What is the gear ratio?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!