20.03.2021

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.

. 21

Faq

Computers and Technology
Step-by-step answer
P Answered by Specialist

// program in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main() {

 // variable

float n;  

cout<<"Enter the initial value:";

//Read the input from the user  

cin>>n;

//Declare variables for storing values at 6, 12 and 18 hours

float hours_6, hours_12, hours_18;  

//Set precision level of floating point number

cout << fixed;

    cout << setprecision(6);

 //calculate values at 6, 12 and 18 hours

hours_6 = n / 2.0;

hours_12 = hours_6 / 2.0;

hours_18 = hours_12 / 2.0;

//display the output

cout<<"After 6 hours: "<<hours_6<<"mg"<<endl;

cout<<"After 12 hours: "<<hours_12<<"mg"<<endl;

cout<<"After 18 hours: "<<hours_18<<" mg"<<endl;

return 0;

}

Explanation:

Read an input from the user. Set the precision to 6 for displaying the result up to 6 decimal places. The first half life at 6 hours can be calculated by dividing the input by 2. The half life at 12 hours can be found out by dividing the half life value at 6 hours by 2. Similarly at 18 hours, we find the half life value by dividing the half life value at 12 hours by 2.

Output:

Enter the initial value:100                                                                                                

After 6 hours: 50.000000 mg                                                                                                

After 12 hours: 25.000000 mg                                                                                              

After 18 hours: 12.500000 mg  

Computers and Technology
Step-by-step answer
P Answered by Specialist

// program in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main() {

 // variable

float n;  

cout<<"Enter the initial value:";

//Read the input from the user  

cin>>n;

//Declare variables for storing values at 6, 12 and 18 hours

float hours_6, hours_12, hours_18;  

//Set precision level of floating point number

cout << fixed;

    cout << setprecision(6);

 //calculate values at 6, 12 and 18 hours

hours_6 = n / 2.0;

hours_12 = hours_6 / 2.0;

hours_18 = hours_12 / 2.0;

//display the output

cout<<"After 6 hours: "<<hours_6<<"mg"<<endl;

cout<<"After 12 hours: "<<hours_12<<"mg"<<endl;

cout<<"After 18 hours: "<<hours_18<<" mg"<<endl;

return 0;

}

Explanation:

Read an input from the user. Set the precision to 6 for displaying the result up to 6 decimal places. The first half life at 6 hours can be calculated by dividing the input by 2. The half life at 12 hours can be found out by dividing the half life value at 6 hours by 2. Similarly at 18 hours, we find the half life value by dividing the half life value at 12 hours by 2.

Output:

Enter the initial value:100                                                                                                

After 6 hours: 50.000000 mg                                                                                                

After 12 hours: 25.000000 mg                                                                                              

After 18 hours: 12.500000 mg  

Computers and Technology
Step-by-step answer
P Answered by Specialist

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

Computers and Technology
Step-by-step answer
P Answered by PhD

Yes, it will be after 6 hours: 50 mg, after 12 hours: 25 mg, and after 18 hours: 12.5 mg

Explanation:

Remember coral is a functional programming language and follows Pythons functional programming paradigm. Remember Python supports functional, imperative as well as OOPS paradigm.

The function will be:

def void calcamtleft(int amt):

   integer a=6

   integer time=6

   integer i=1

   while amt> 0:

       amt=amt/2

       print("After"+time+"  hours:" +amt+"mg")

       i++

       time=a* i

Hence in first loop amt=100

new amt=100/2=50

After 6 hours: 50 mg ( this will be printed)

i will increment then, and time will be = 6 *2 =12

now input amt=50

new amt=50/2=25

After 12 hours 25 mg (this will be output)

i will increment then, and time will be = 6 *3 =18

now input amt=25

new amt=25/2=12.5

After 18 hours 12.5 mg (this will be output)

i will increment then, and time will be = 6 *4 =24

now input amt=12.5/2= 6.25

new amt=6.25/2= 3.125

After 24 hours 3.125 mg (this will be output)

i will increment then, and time will be = 6 *5 =30

now input amt=3.125

new amt=3.125/2= 1.5625

After 30 hours 1.5625 mg

And this will continue till amt>0

Computers and Technology
Step-by-step answer
P Answered by Master

Explanation:

if the original mass is let's say an unknown mass of x milli grams...by half life period it will have reduced by half which will be

\frac{x}{2} milli \: grams

so as the next 6 hours go by to make 12 hours the remaining mass will have reduced again by a half

\frac{x}{4} milli \: grams

this continues for the next 6 hours to make 18 hours

\frac{x}{8} milli \: grams

I hope this is helpful

Computers and Technology
Step-by-step answer
P Answered by Specialist

Explanation:

if the original mass is let's say an unknown mass of x milli grams...by half life period it will have reduced by half which will be

\frac{x}{2} milli \: grams

so as the next 6 hours go by to make 12 hours the remaining mass will have reduced again by a half

\frac{x}{4} milli \: grams

this continues for the next 6 hours to make 18 hours

\frac{x}{8} milli \: grams

I hope this is helpful

Engineering
Step-by-step answer
P Answered by Master

True, a retractable service pit cover can help other shop employees from falling into the pit while another technician is in the pit servicing a car.

Retractable service pit cover is a special cover made to cover service pit which aid inspection and repair of vehicle in an auto workshop.

Retractable service pit ensure safety of workshop technicians around service pits.Retractable service pits aid proper inspection of the beneath of the vehicleRetractable service pits enable the technician to have a close view of the vehicle in repair.The pit also serves as guide to short-eyed people or people to are not aware of the structure.In essence, the pit prevent against injury or death of workers and occupier.

In conclusion, the retractable service pit cover help other shop employees from falling into the pit even if they are aware of the structure.

Learn more about retractable service pit in picture attached

Engineering
Step-by-step answer
P Answered by PhD

Code:

#include <iostream>

using namespace std;

int main()

{

  int Car_Year;

  cout<<"Please Enter the Car Model."<<endl;

  cin>>Car_Year;    

 if (Car_Year<1967)

 {

cout<<"Few safety features."<<endl;

 }

else if (Car_Year>1971 && Car_Year<=1991)

{

cout<<"Probably has head rests."<<endl;

}

else if (Car_Year>1991 && Car_Year<=2000)

{

cout<<"Probably has antilock brakes."<<endl;

}

else if (Car_Year>2000)

{

cout<<"Probably has airbags."<<endl;

  }

else

{

cout<<"Invalid Selection."<<endl;

}

  return 0;

}

Output:

Please Enter the Car Model.

1975

Probably has head rests.

Please Enter the Car Model.

1999

Probably has antilock brakes.

Please Enter the Car Model.

2005

Probably has airbags.

Please Enter the Car Model.

1955

Few safety features.

Explanation:

We were required to implement multiple If else conditions to assign car model year with the corresponding features of the car.

The code is tested with a wide range of inputs and it returned the same results as it was asked in the question.

Engineering
Step-by-step answer
P Answered by Master

NTQ

Explanation:

The given sequence is

BHE : FLI : JPM

If is clear that, alphabets on first places are B, F, J. Difference between their place vales is 4.

B+4=F,F+4=J ; so alphabet on first place of next term of sequence is J+4=N.

Similarly, alphabets on second places are H, L, P. Difference between their place vales is 4.

H+4=L,L+4=P ; so alphabet on second place of next term of sequence is P+4=T.

Alphabets on third places are E, I, M. Difference between their place vales is 4.

E+4=I,I+4=M ; so alphabet on third place of next term of sequence is M+4=Q.

Therefore, the next term is NTQ.

Try asking the Studen AI a question.

It will provide an instant answer!

FREE