When floatfield is set to fixed, floating-point values are written using fixed-point notation: the value is represented with exactly as many digits in the decimal part as specified by the precision field (precision) and with no exponent part.
http://www.cplusplus.com/reference/ios/fixed/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iomanip>
int main()
{
float membership = 2500.00;
std::cout <<"Membership fee \t\t\tYear\n"
<< "-------------------------------------\n";
for( int year = 2; year <= 6; ++year)
{
membership += (membership * 0.04);
std::cout << std::fixed << std::setprecision(2);
std::cout << membership << " \t\t\t " << year << std::endl;
}
return 0;
}