Setprecision <iomanip> help!

This is my program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*The East Coast sales division of a company generates 58 percent of total sales. Based on that percentage, 
write a program that will predict how much the East Coast 
	division will generate if the company has $8.6 million in sales this year.*/


#include "stdafx.h"
#include <iostream>
#include <iomanip>
using namespace std;

void main()
{
	cout << "The East Coast division of a company generates 58% of total sales" << endl;
	cout << ". Based on this percentage, if the company's sales are $8.6 million," << endl;
	cout << " the East Coast division will produce " << endl;

	double east_coast(.58), west_coast(.42), total_sales(8600000);

	east_coast =  east_coast*total_sales;
	
	cout << setprecision(3) << east_coast << endl;

	cout << " and the West Coast division will produce " << endl;

	west_coast = west_coast*total_sales;

	cout << setprecision(3) << west_coast << endl;

	
}

Which keeps outputting:
The East Coast division of a company generates 58% of total sales
. Based on this percentage, if the company's sales are $8.6 million,
 the East Coast division will produce $4.99e+006
 and the West Coast division will produce $3.61e+006
Press any key to continue . . .
Obviously I don't want the "e+006" but I cant seem to get rid of it with the setprecision function. What do I do?
Do you want std::fixed?
 
cout << std::fixed << setprecision(3) << east_coast << endl;
4988000.000
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*The East Coast sales division of a company generates 58 percent of total sales. Based on that percentage, 
write a program that will predict how much the East Coast 
	division will generate if the company has $8.6 million in sales this year.*/

#include <iostream>
#include <iomanip>
using namespace std;

int main(void)
{
	cout << "The East Coast division of a company generates 58% of total sales" << endl;
	cout << ". Based on this percentage, if the company's sales are $8.6 million," << endl;
	cout << " the East Coast division will produce " << endl;

	double east_coast(.58), west_coast(.42), total_sales(8600000);

	east_coast =  east_coast*total_sales;
	
	cout << std::fixed << setprecision(3) << east_coast << endl;

	cout << " and the West Coast division will produce " << endl;

	west_coast = west_coast*total_sales;

	cout << std::fixed << setprecision(3) << west_coast << endl;

	
}

/*Which keeps outputting:
The East Coast division of a company generates 58% of total sales
. Based on this percentage, if the company's sales are $8.6 million,
 the East Coast division will produce $4.99e+006
 and the West Coast division will produce $3.61e+006
Press any key to continue . . .
Obviously I don't want the "e+006" but I cant seem to get rid of it with the setprecision function. What do I do?*/
Topic archived. No new replies allowed.