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)
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...
Question 5 A plant site donated by a township to a manufacturer that plans to open...
Question 5 A plant site donated by a township to a manufacturer that plans to open a new factory should be recorded on the manufacturer's books at ___________. Question 5 options: A. the nominal cost of taking title to it i B. Its fair value C. one dollar (since the site cost nothing but should be included in the balance sheet) D. the value assigned to it by the company's directors Question 6 Which of the following costs are capitalized...
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...
1. What is an ISP (Integrated Service Provider) for supply chains? (1 point) A. A consultant...
1. What is an ISP (Integrated Service Provider) for supply chains? (1 point) A. A consultant agency which integrates the supply chain for companies B. A 2 PL or a 3PL, but not a 4PL C. A company supplying transportation and warehousing services D. A logistics service company specialized in suppling VAS (value added services) 2. What characterizes a 4 PL? (1 point) A. They are non-asset based and provides integrated services primarily supplied by asset based providers, for example...
QUESTION 1 ? What is the relationship between family dysfunction and schizophrenia? a. ?Research has substantiated...
QUESTION 1 ? What is the relationship between family dysfunction and schizophrenia? a. ?Research has substantiated a link between family dysfunction and schizophrenia but can't say which causes the other. b. ?Family dysfunction is a major causative factor for schizophrenia. c. ?Research has failed to substantiate a direct causal link between family dysfunction and schizophrenia. d. ?Family dysfunction plays a minor role in developing schizophrenia. 1.00000 points    QUESTION 2 ? Chuck has no life plan; he simply lives from...
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:...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT