Answer to Question #311503 in Java | JSP | JSF for sesame seeds

Question #311503

A milk carton can hold 3.78 liters of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one liter of milk is 0.38, and the profit of each carton of milk is 0.27.


Write a program that does the following:

a. Prompts the user to enter the total amount of milk produced in the morning

b. Outputs the number of milk cartons needed to hold milk (Round your answer to the nearest integer.)

c. Outputs the cost of producing milk

d. Outputs the profit for producing milk


1
Expert's answer
2022-03-14T13:04:26-0400
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    System.out.println("Enter total amount of milk: ");
    double totalAmountOfMilk = Double.parseDouble(scanner.nextLine());

    System.out.println("The number of milk cartons needed to hold milk:");
    int numberOfMilkCartoons = (int) (totalAmountOfMilk / 3.78);
    System.out.println(numberOfMilkCartoons);

    System.out.println("The cost of producing one liter of milk:");
    double costOfProducingOneLiterOfMilk = totalAmountOfMilk * 0.38;
    System.out.println(costOfProducingOneLiterOfMilk);

    System.out.println("The output of the profit for producing milk:");
    double profitForProducingMilk = numberOfMilkCartoons * 0.27;
    System.out.println(profitForProducingMilk);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS