C++ programming exercise:
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 and the profit of each carton of milk vary from farm to farm.
Write a program that prompts the user to enter:
The total amount of milk produced in the morning.
The cost of producing one liter of milk.
The profit on each carton of milk.
The program then outputs:
The number of milk cartons needed to hold milk.
The cost of producing milk.
The profit for producing milk.
Program:
#include <iostream>
#include <iomanip>
#include<cmath>
using namespace std;
int main()
{
//constant to indicate how many liters of milk can
each carton hold
const double MILK_IN_EACH_CARTON = 3.78;
//variable declarations
double milkProduced, productionCostPerLiter,
profitPerCarton;
int cartonsRequired;
double costOfProducingMilk, profit;
//prompt and read milk produced
cout << "Enter total amount of milk
produced in the morning: ";
cin >> milkProduced;
//prompt and read cost of producing 1 liter of
milk
cout << "Enter the cost of producing one
liter of milk: ";
cin >> productionCostPerLiter;
//prompt and read profit on each carton of
milk
cout << "Enter profit on each carton of
milk: ";
cin >> profitPerCarton;
//calculate the number of carton required
cartonsRequired = (round) (milkProduced /
MILK_IN_EACH_CARTON);
//calculate the cost of producing milk
costOfProducingMilk = productionCostPerLiter *
milkProduced;
//calculate the profit
profit = cartonsRequired *
profitPerCarton;
//display output
cout << "\nNumber of cartons required: "
<< cartonsRequired << endl;
cout << "Cost for producing milk: $"
<< fixed << setprecision(2) <<
costOfProducingMilk << endl;
cout << "Profit for producing milk: $"
<< fixed << setprecision(2) << profit <<
endl;
return 0;
}
Output:

Program Screenshot:

C++ programming exercise: A milk carton can hold 3.78 liters of milk. Each morning, a dairy...
C++ Please 1. A milk carton can hold 3.78 litres of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one litre of milk is $0.2, and the profit of each carton of milk is $0.04. 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...
c++ please
A farmer ships bottles of olive oil to a supermarket. Each olive oil bottle holds 2.5 liters of oil. The cost of producing one liter of olive oil is 1.2 JD, and the profit of each bottle of oil is 0.35 JD. Write a program that does the following: 1. Prompts the user to enter the total amount of oil (liters) produced. 2. Outputs the number of olive oil bottles needed to hold olive oil produced. (Round the...
In C++
Amanda and Tyler opened a business that specializes in shipping
liquids, such as milk, juice, and water, in cylindrical containers.
The shipping charges depend on the amount of the liquid in the
container. (For simplicity, you may assume that the container is
filled to the top.) They also provide the option to paint the
outside of the container for a reasonable amount. Write a program
that does the following:
Prompts the user to input the dimensions (in feet)...