Answer to Question #311493 in C++ for Ali

Question #311493

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.


1
Expert's answer
2022-03-14T13:04:31-0400

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;
		}
	}
	
	
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment