Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java please Required Skills Inventory - Use variables to name, store, and retrieve values - Use System. out. print to prompt the user for input

java please
image text in transcribed
image text in transcribed
Required Skills Inventory - Use variables to name, store, and retrieve values - Use System. out. print to prompt the user for input - Use a Scanner to collect user input - Use math operators to construct an expression - Use String literals to define a String value - Output to console with System. out. printf - Use format specifiers to format floating point values in strings - Use escape sequences to construct a String expression Problem Description and Given Info A half-life is the amount of time it takes for a substance or entity to fall to haif its original value. Caffeine has a half ife of about 6 hours in humans. This means that if a human ingests 100mg of caffeine, then after 6 hours there will only be 50mg of caffene left in their system. and after 12 hours there will only be 25mg left in their system. As the term "half iffe implies, the amount decreases by half each time interval, You write a Java program that will take, as input, an amount of caffeine ingested, and then compute and display the aimount of caffeine that will still be in the person's system after 6,12 , and 18 hours. 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 foating-point numbers. Note that the initial amount of caffeine will be entered as a double value, and the output values will also be double floating point values. Here are some examples of what the user should see when the program runs. Example 1 Enter caffeine amount (in mg):100 After 6 hours ; 50.00mg After 12 hours : 25.00mg After 18 hours : 12.50mg After 6 hours: 50.00mg After 12 hours : 25.00ng After 18 hours : 12.50mg Example 2 Enter caffeine amount (in mg) : 40 After 6 hours : 20.00mg After 12 hours : 10.00mg Aftes 18 hours : 5.00mg For the given inputs, make sure that your program output looks exactly like the examples above (including spelling, capitalization. punctuation, spaces, and decimal points). Hints and Helpful Info: - Remember that you can use System. out. printf to format your outputs so that they have the required number of decimal places Need Help? Additional help resources are available by clicking on the words "Need Help?" at the bottom of this page, and search for help or ask a questiont \begin{tabular}{l|l} Las \\ Acrivir & 5.10.1: Caffeine Levels (individual Assignment) \end{tabular} 0/100 Caffeine.java Load default template

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions