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
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);
}
Comments
Leave a comment