Question

Write code in Java Question 1 Directions: 1. A half-life is the amount of time it...

Write code in Java

Question 1 Directions: 1. 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

Question 2. The East Coast sales division of a company generates 65 percent of total sales. Based on that percentage, write a program that will predict how much the East Coast division will generate based on the input. Hint: Use the value 0.65 to represent 65 percent.

Ex: If the input is:

8300000

the output is:

East coast sales prediction: $5,395,000.00

Homework Answers

Answer #1

import java.util.Scanner;

public class LabProgram {

    public static void main(String[] args) {
        Scanner scnr = new Scanner(System.in);
        double caffeineMg;

        caffeineMg = scnr.nextDouble();

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

import java.util.Scanner;

public class LabProgram {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double sales = in.nextDouble() * 0.65;
        System.out.printf("East coast sales prediction: $%,.2f\n", sales);
    }
}
Know the answer?
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
Similar Questions
in java A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose...
in java A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output is the miles walked. 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: 5345 the output is: 2.67 Your program must define and call a method: public static double stepsToMiles(int userSteps)
Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost...
Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to drive those miles. All items are of type double. If the method is called with 50 20.0 3.1599, the method returns 7.89975. Define that method in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both doubles). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your drivingCost() method three times. Output each floating-point value...
2.13 LAB: Driving cost - methods Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and...
2.13 LAB: Driving cost - methods Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to drive those miles. All items are of type double. If the method is called with 50 20.0 3.1599, the method returns 7.89975. Define that method in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both doubles). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your drivingCost() method...
please write the code in java so it can run on jGRASP import java.util.Scanner; 2 import...
please write the code in java so it can run on jGRASP import java.util.Scanner; 2 import java.io.*; //This imports input and output (io) classes that we use 3 //to read and write to files. The * is the wildcard that will 4 //make all of the io classes available if I need them 5 //It saves me from having to import each io class separately. 6 /** 7 This program reads numbers from a file, calculates the 8 mean (average)...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as...
Java question, Please answer everything. Thank you Answer the following questions as briefly (but completely) as possible: What is a checked exception, and what is an unchecked exception? What is NullPointerException? Which of the following statements (if any) will throw an exception? If no exception is thrown, what is the output? 1: System.out.println( 1 / 0 ); 2: System.out.println( 1.0 / 0 ); Point out the problem in the following code. Does the code throw any exceptions? 1: long value...
I only need/want question #4 answered. Only Question 4! Thanks! Twin Falls Community Hospital is a...
I only need/want question #4 answered. Only Question 4! Thanks! Twin Falls Community Hospital is a 250-bed, not-for-profit hospital located in the city of Twin Falls, the largest city in Idaho’s Magic Valley region and the seventh largest in the state. The hospital was founded in 1972 and today is acknowledged to be one of the leading healthcare providers in the area. Twin Falls’ management is currently evaluating a proposed ambulatory (outpatient) surgery center. Over 80 percent of all outpatient...
COST ACCOUNTING Gizmos, Inc. incorporated and will begin operations on January 1, 2021. Its primary business...
COST ACCOUNTING Gizmos, Inc. incorporated and will begin operations on January 1, 2021. Its primary business is the manufacture and sale of gadgets. Because cash resources are limited, the company anticipates the need to have access to capital during the first year of operations and seeks to establish a line of credit with a local bank. The bank requires a complete operating and cash budget and pro-forma financial statements for 2021 as part of the loan application. The following information...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
MATHEMATICS 1. The measure of location which is the most likely to be influenced by extreme...
MATHEMATICS 1. The measure of location which is the most likely to be influenced by extreme values in the data set is the a. range b. median c. mode d. mean 2. If two events are independent, then a. they must be mutually exclusive b. the sum of their probabilities must be equal to one c. their intersection must be zero d. None of these alternatives is correct. any value between 0 to 1 3. Two events, A and B,...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...