I have a program that calculates population growth. It seems to be working but after when the population exceed 1 million it is output as a decimal number raised to a power of ten. (is this called scientic notation? exponential form? i forget.)
Is there anyway to output the data as a full number? Here is the code for the 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;
}
The std::fixed
manipulator, used in conjunction with std::setprecision
should help you (remember to #include <iomanip>
).
i suggest reading about std::scientific
: http://msdn.microsoft.com/en-us/library/szb722da(VS.71).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With