954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

decimals and percentage

How can I set the Actual rolls and Expected rolls to no decimal,
and Actual percentage and Expected percentage to 1 decimal plus a % symbol ?

http://images.plurk.com/a2f077138ef908ce71f46b08909c998d.jpg

cout << "Point" << setw(17) << "Number of Rolls" << setw(17) << "Actual Percent" 					<< setw(17) << "Expected Rolls" << setw(17) << "Expected Percent" << endl;

for (int face = 2; face < arraySize; face++)
  cout << setw(5) << face << setw(17) << frequency[face] << setw(17) << (frequency[face]/roll)  << setw(17) << (intRepeats / expected[face]) << setw(17)  << expected[face] << endl;
chuyauchi
Newbie Poster
24 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 
firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
 
http://www.cplusplus.com/reference/iostream/ios_base/precision/

Is it possible to no do the cout by many lines? Can I just add something to my code?

chuyauchi
Newbie Poster
24 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

Yes you can use setprecision just like you are using setw.

firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You