Question

IN JAVA CSCI 1301: A half-life is the amount of time it takes for a substance...

IN JAVA CSCI 1301: 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

0 0
Add a comment Improve this question Transcribed image text
Answer #1
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();

        caffeineMg = caffeineMg/2;
        System.out.printf("After 6 hours: %.2f mg\n", caffeineMg);
        System.out.printf("After 12 hours: %.2f mg\n", caffeineMg/2);
        System.out.printf("After 24 hours: %.2f mg\n", caffeineMg/8);

    }
}

Add a comment
Know the answer?
Add Answer to:
IN JAVA CSCI 1301: A half-life is the amount of time it takes for a substance...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java 6.16 LAB: Adjust list by normalizing

    When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This adjustment can be done by normalizing to values between 0 and 1, or throwing away outliers. For this program, adjust the values by dividing all values by the largest value. The input begins with an integer indicating the number of floating-point values that follow. Assume that the list will always contain fewer than 20 floating-point values. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: System.out.printf("%.2f", yourValue); Ex: If the input is: 5 30.0 50.0 10.0 100.0 65.0 the output is: 0.30 0.50 0.10 1.00 0.65  The 5 indicates that there are five floating-point values in the list, namely 30.0, 50.0, 10.0, 100.0, and 65.0. 100.0 is the largest value in the list, so each value is divided by 100.0. For coding simplicity, follow every output value by a space, including the last one. import java.util.Scanner;  public class LabProgram {    public static void main(String[] args) {       /* Type your code here. */    } }

  • In Java The following equations estimate the calories burned when exercising (source): Women: Calories = (...

    In Java The following equations estimate the calories burned when exercising (source): Women: Calories = ( (Age x 0.074) — (Weight x 0.05741) + (Heart Rate x 0.4472) — 20.4022 ) x Time / 4.184 Men: Calories = ( (Age x 0.2017) + (Weight x 0.09036) + (Heart Rate x 0.6309) — 55.0969 ) x Time / 4.184 Write a program using inputs age (years), weight (pounds), heart rate (beats per minute), and time (minutes), respectively. Output calories burned for...

  • Musical note frequencies

    3.11 LAB: Musical note frequenciesOn a piano, a key has a frequency, say f0. Each higher key (black or white) has a frequency of f0 * rn, where n is the distance (number of keys) from that key, and r is 2(1/12). Given an initial key frequency, output that frequency and the next 4 higher key frequencies.Output each floating-point value with two digits after the decimal point, which can be achieved as follows:System.out.printf("%.2f", yourValue);Ex: If the input is:440.0(which is the A...

  • (Show the work for these questions) 35. What is the half-life of a medication for which...

    (Show the work for these questions) 35. What is the half-life of a medication for which only 12.5% remains after 24 hours? A. 4 hours B. 8 hours C. 16 hours D. None of the above 36. What is the half-life of an orally administered medicated syrup if its level is down to 61⁄4 % after 12 hours? A. 6 hours B. 4 hours C. 3 hours D. 2 hours 37. When a 500-mg medical dosage has degenerated to approximately...

  • can anyone solve a , b and c part 7 Chapter Task The Half-Life of Caffeine...

    can anyone solve a , b and c part 7 Chapter Task The Half-Life of Caffeine Caffeine is a stimulant found in many products, such as coffee, tea, pop, and chocolate. When you drink a cup of tea or eat a chocolate bar, you ingest caffeine. Your body breaks down caffeine slowly. As with other drugs, caffeine has a half-life in the body. The half-life of caffeine in a typical nonsmoking adult is 5.5 h. Caffeine Content (mg) 250 mL...

  • time does not 1. When you take a dose of medicine, the amount that remains in your bloodstream over remain constant. One popular allergy medication requires a daily dose of 10 mg. amount of the...

    time does not 1. When you take a dose of medicine, the amount that remains in your bloodstream over remain constant. One popular allergy medication requires a daily dose of 10 mg. amount of the medication in the bloodstream at various times after taking the medication. The table shows the Time since taking Amount remaining 10 0 3.30 1.09 0.36 0.12 12 16 a. What type of function might be an appropriate model for these data and why? b. Use...

  • 1) Repeated doubling, in which each doubling occurs in the same amount of time, is a...

    1) Repeated doubling, in which each doubling occurs in the same amount of time, is a hallmark of linear growth. A) True B) False 2) Money in a bank account earning compound interest at an annual percentage rate of 3% represents an example of linear growth. A) True B) False 3) Suppose you had a magic bank account in which your balance doubled each day. If you started with just $ 1, you'd be a millionaire in less than a...

  • Java please At this point in your life most of you have or have had a...

    Java please At this point in your life most of you have or have had a job. One of the aspects of a job is dealing with taxes. Benjamin Franklin said “in this world nothing can be said to be certain, except death and taxes.” There are many types of taxes. Some of the most familiar taxes are state sales tax, federal and state income tax and local property tax. Write a program that will compute and print the federal,...

  • Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In...

    Using Merge Sort: (In Java) (Please screenshot or copy your output file in the answer) In this project, we combine the concepts of Recursion and Merge Sorting. Please note that the focus of this project is on Merging and don't forget the following constraint: Programming Steps: 1) Create a class called Art that implements Comparable interface. 2) Read part of the file and use Merge Sort to sort the array of Art and then write them to a file. 3)...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT