/*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>
usingnamespace 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?
/*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>
usingnamespace 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?*/