An egg distribution company uses different sizes of packings for eggs, that is, 30 eggs packing, 24 eggs packing, 18 eggs packing, 12 eggs packing and 6 eggs packing. Write a program which prompts user to enter total number of eggs (input validation is always must) to be packed and then calculate how many packings of each size will be possible. Also tell if there will be any eggs left to be packed.
Here is program:
int main()
{
int eggs;
int totaleggs;
int i = 0;
cout << "Enter eggs: " << endl;
cin >> eggs;
for (; eggs < 0; i++)
{
if (eggs == 30)
{
totaleggs = eggs - 30;
cout << "Pakings eggs 30: " << i << endl;
}
if (eggs == 18)
{
totaleggs = eggs - 18;
cout << "Pakings eggs 18: " << i << endl;
}
if (eggs == 12)
{
totaleggs = eggs - 12;
cout << "Pakings eggs 12: " << i << endl;
}
if (eggs == 6)
{
totaleggs = eggs - 6;
cout << "Pakings eggs 6: " << i << endl;
}
if (eggs < 6)
{
cout << "Any eggs left to be packed." << endl;
}
}
}
Comments
Leave a comment