Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A box of cookies can hold 24 cookies, and a container can hold 75 boxes of cooki

ID: 3676335 • Letter: A

Question

A box of cookies can hold 24 cookies, and a container can hold 75 boxes of cookies. Write a program that prompts the user to enter the total number of cookies, the number of cookies in a box, and the number of cookie boxes in a container. The program then outputs the number of boxes and the number of containers to ship the cookies. Note that each box must contain the specified number of cookies, and each container must contain the specified number of boxes. If the last box of cookies contains less than the number of specified cookies, you can discard it and output the number of leftover cookies. Similarly, if the last container contains less than the number of specified boxes, you can discard it and output the number of leftover boxes.

Explanation / Answer

/*C++ program that prompts for total number of cookies
and then find the number of boxes, containers and left boxes
and left cookies to conole*/
#include <iostream>;
using namespace std;
int main()
{

   //cookie sin a box
   const int BOX=24;
   const int CONTAINER=75;
   int cookies;
   int boxes;
   int leftCookies;
   int containers;
   int leftBoxes;

   cout<< "Enter total number of cookies:";
   //read cookies
   cin >> cookies;


   //find the number of boxes to store cookies
   boxes = cookies / BOX;
   //find the remainder of cookies by modulo 24
   leftCookies = cookies % BOX;

   //find the number of cintainers to store cookie boxes
   containers = boxes / CONTAINER;

   //find the remainder of boxes by modulo 75
   leftBoxes = boxes % CONTAINER;

   cout<< "The total number of cookies is:"<< cookies<< endl;

   //print
   cout << "# of boxes required = " << boxes << endl;
   cout << "# of containers required = " << containers << endl;

   cout << "# of leftover cookies = " << leftCookies << endl;
   cout << "# of leftover boxes = " << leftBoxes << endl;

   //pause the program output on console
   system("pause");
   return 0;

}

sample output:

Enter total number of cookies:2000
The total number of cookies is:2000
# of boxes required = 83
# of containers required = 1
# of leftover cookies = 8
# of leftover boxes = 8

Note : it is C ++ program