Respuesta :
ANSWER
The cpp program is given below.
#include <iostream>
using namespace std;
int main() {
// variables declared and initialized with given values
int box_capacity = 24;
int boxes = 0;
int container_capacity = 75;
int containers =0;
int cookies;
// user input taken for number of cookies
cout<< "Enter the number of cookies to be shipped: ";
cin>>cookies;
// boxes and containers computed based on given values
while(cookies>box_capacity)
{
cookies = cookies - box_capacity;
boxes = boxes +1;
if(boxes == container_capacity)
containers = containers +1;
}
// outputting the required boxes and containers
cout<<boxes<< " number of boxes " << " and " <<containers<< " number of containers are required to ship the cookies." <<endl;
return 0;
}
OUTPUT1
Enter the number of cookies to be shipped: 23
0 number of boxes and 0 number of containers are required to ship the cookies.
OUTPUT2
Enter the number of cookies to be shipped: 230
9 number of boxes and 0 number of containers are required to ship the cookies.
OUTPUT3
Enter the number of cookies to be shipped: 2300
95 number of boxes and 1 number of containers are required to ship the cookies.
EXPLANATION:
The program is described below.
1. Variables are created and initialized to hold all the given values for capacity.
2. Variables are created and initialized to 0 to hold number of boxes and containers.
3. User input is taken in the variable, cookies.
4. All the variables are declared as integers since no decimals are involved.
5. Inside while loop, the number of boxes and containers are computed.
6. The while loop executes since value of cookies does not falls below the capacity of the box, box_capacity.
7. The program terminates with the return statement.
8. Three different outputs are shown based on the different values of cookies.
9. The output shows the values of variables boxes and containers based on the user input for cookies variable.