can one of you guys maybe explain the following function to me?
the manager of a packaging business where all the containers have one size, namely 2000cm3. a C++ program that will determine how many containers will be needed for every order. For example: If the items are all of size 25cm3, the number that will fit into one container is 2000/25 = 80. If 200 items should be packed, 3 containers will be needed.
write a function, namely nrFitInContainer, of return type int. There is one value parameter only. The function receives an int value, namely the size of the individual items that should be packed. The function should then calculate how many of these items will fit into one container and return the answer as an integer.
Coding:
#include <iostream>
using namespace std;
const int CONTAINER_SIZE = 2000;
// The function nrFitInContainer should be inserted here if I'm correct?
int main( )
{
int size, nrInEveryContainer;
cout << "What is the size of every item? ";
cin >> size;
if (size > CONTAINER_SIZE)
cout << "Items are too big. Sorry, we cannot help you."
<< endl << endl;
else
{
nrInEveryContainer = nrFitInContainer(size);
cout << nrInEveryContainer
<< " items fit into one container." << endl;
}
return 0;
}
the manager of a packaging business where all the containers have one size, namely 2000cm3. a C++ program that will determine how many containers will be needed for every order. For example: If the items are all of size 25cm3, the number that will fit into one container is 2000/25 = 80. If 200 items should be packed, 3 containers will be needed.
write a function, namely nrFitInContainer, of return type int. There is one value parameter only. The function receives an int value, namely the size of the individual items that should be packed. The function should then calculate how many of these items will fit into one container and return the answer as an integer.
Coding:
#include <iostream>
using namespace std;
const int CONTAINER_SIZE = 2000;
// The function nrFitInContainer should be inserted here if I'm correct?
int main( )
{
int size, nrInEveryContainer;
cout << "What is the size of every item? ";
cin >> size;
if (size > CONTAINER_SIZE)
cout << "Items are too big. Sorry, we cannot help you."
<< endl << endl;
else
{
nrInEveryContainer = nrFitInContainer(size);
cout << nrInEveryContainer
<< " items fit into one container." << endl;
}
return 0;
}