Problem Statement – A large apple juice carton can hold 3.35 liters of juice. Ea
ID: 3753331 • Letter: P
Question
Problem Statement – A large apple juice carton can hold 3.35 liters of juice. Each morning, Dale’s Apple Orchard ships cartons of apple juice to a nearby Costco. The profit of producing one liter of apple juice is $0.37.
Write a program that:
Gets the total amount of apple juice Dale’s Apple Orchard produced on a given day (in liters) as input from the user.
Given the input, the program should then calculate:
The total number of cartons needed, and
The profit of producing the apple juice
Next, the program should print the following information on screen:
The number of cartons needed, and
The profit of producing the apple juice
Explanation / Answer
#include <iostream>
using namespace std;
int main ()
{
cout << "Enter total amount of apple juice in liters ";
double juice;
cin >> juice;// Will get number of liters from user
double cartonCapacity = 3.5; // As mentioned in the question
double profitPerLiter = 0.37; // As mentioned in the question
int totalCartons = (int)(juice / cartonCapacity) + 1; // Will give you the total number of cartons needed
double totalProfit = juice * profitPerLiter; // Will give you the total profit
// Logging the results here
cout << "Total number of cartons needed are: " << totalCartons << " ";
cout << "Total profit is: " << totalProfit << " ";
}
Output for a sample input
Enter total amount of apple juice in liters
11
Total number of cartons needed are: 4
Total profit is: 4.07
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.