I have a program that calculates population growth. It seems to work, but after the population exceeds 1 million, it is displayed as a decimal number increased to ten. (This is called scientific notation? exponential form? I forget.)
In any case, to output the data as a complete number? Here is the code to output where I will have to convert it.
#include "header.h" void output (float currentPopulation, float years, float birthRate, float deathRate) { cout << "the populaion in " << years << " years will be: " << estimatedPopulation (currentPopulation, years, birthRate, deathRate) << endl; }
New code:
#include "header.h" void output (float currentPopulation, float years, float birthRate, float deathRate) { cout << "the populaion in " << years << " years will be: " << fixed << setprecision(0) << estimatedPopulation (currentPopulation, years, birthRate, deathRate) << endl; }
darko source share