Activity: If-Else and Eggs (iPad)

The Assignment

Eggs are packaged in cartons holding 1 dozen eggs and then boxes that store 5 cartons each. Given a number of eggs by the user, write a program to determine how many cartons and boxes the packager will need. Your if-else logic should consider whether a partial carton and/or box is needed. If so, add one (1) to your totals.

With your partner, begin by creating a new C++ file called Eggs.cpp in the C++ compiler. Next, copy and paste this starter code into the file:

#include <iostream>
using namespace std; 

int main() 
{
   /* Declare a variable to store the number of eggs (a short)
      since we must declare a variable before storing to it... */
   
   // Input the number of eggs...              

   // Declare two integer variables, each initialized to 0...
   int num_cartons = 0, num_boxes = 0;

   // Compute and store the number of cartons needed...

   // Compute and store the number of boxes needed...

   // Output the results....
   cout << "You need " << num_boxes << " boxes and " << num_cartons 
        << " cartons" << endl;

   // return "success" to the operating system (OS)...
   return 0;
}

Modify the code to complete the assignment. When you have completed the assignment, demonstrate it for the instructor.