Question #93408

Define c++ function CalculateYears() that stimulates the population growth and return the year in which female will be greater than or equal to male population if the currently we have 1750000 male at growth rate is 25% and 1500000 female at thegrowth rate is 35%

Expert's answer

int CalculateYears()
{
	int result = 0;

	const int maleCount = 1750000;
	const int femaleCount = 1500000;

	int maleCurrentCount   = maleCount;
	int femaleCurrentCount = femaleCount;

	while (femaleCurrentCount < maleCurrentCount)
	{
		++result;

		femaleCurrentCount += (femaleCurrentCount / 100.0 * 35.0);
		maleCurrentCount   += (maleCurrentCount / 100.0 * 25.0);
	}

	return result;
}

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!

LATEST TUTORIALS
APPROVED BY CLIENTS