Respuesta :
Answer:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double caffeineMg;
cin>>caffeineMg;
cout<<"After 6 hours: "<<fixed<<setprecision(2)<<caffeineMg/2.0<<" mg\n";
cout<<"After 12 hours: "<<fixed<<setprecision(2)<<caffeineMg/4.0<<" mg\n";
cout<<"After 24 hours: "<<fixed<<setprecision(2)<<caffeineMg/8.0<<" mg\n";
return 0;
}
Explanation:
- Declare a variable for caffeine and take the input from user.
- Print the results by dividing the caffeine by relevant Half Life.
- Use setprecision function to display the result up to 2 decimal places.
The program is a sequential program, and does not require loops or conditional statements.
The program in Python, where comments are used to explain each line is as follows:
#This gets input for the Caffeine Amount
caffeineMg = float(input("Caffeine Amount: "))
#This prints the amount after 6 hours
print("After 6 hours: {:.2f}". format(caffeineMg/2.0))
#This prints the amount after 12 hours
print("After 12 hours: {:.2f}". format(caffeineMg/4.0))
#This prints the amount after 24 hours
print("After 24 hours: {:.2f}". format(caffeineMg/8.0))
Read more about sequential program at:
https://brainly.com/question/17970226