Lee_assig25 - << "are...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 //Cheu Lee Assig 25 #include <iostream> using std::cout using std::cin using std::endl using std::fixed #include <iomanip> using std::setprecision using std::setw int main() { const int PEOPLE = 5 const int PRODUCTS = 6 double sales[PEOPLE][PRODUCTS] = { 0.0 } double value double totalSales double productSales[ PRODUCTS ] = { 0.0 } int salesperson int product cout << "Enter the salesperson (1-4), product number (1-5) and total sales."<<endl cout << "Enter -1 for the program to total input.\n" cin >> salesperson while ( salesperson != -1 ) { cin >> product >> value sales[ salesperson ][ product ] += value cin >> salesperson } cout << "\nThe total sales for each sales person " << "are displayed\nat the end of each row," << "and the total sales for each\nproduct "
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: &lt;&lt; &quot;are displayed at the bottom of each column.\n&quot; &lt;&lt; setw( 10 ) &lt;&lt; 1 &lt;&lt; setw( 10 ) &lt;&lt; 2 &lt;&lt; setw( 10 ) &lt;&lt; 3 &lt;&lt; setw( 10 ) &lt;&lt; 4 &lt;&lt; setw( 10 ) &lt;&lt; 5 &lt;&lt; setw( 12 ) &lt;&lt; &quot;Total\n&quot; &lt;&lt; fixed &lt;&lt; setprecision( 2 ) for ( int i = 1 i &lt; PEOPLE totalSales = 0.0 cout &lt;&lt; i for ( int j = 1 j &lt; PRODUCTS totalSales += sales[ i ][ j ] cout &lt;&lt; setw( 10 ) &lt;&lt; sales[ i ][ j ] productSales[ j ] += sales[ i ][ j ] } cout &lt;&lt; setw( 10 ) &lt;&lt; totalSales &lt;&lt; '\n' } cout &lt;&lt; &quot;\nTotal&quot; &lt;&lt; setw( 6 ) &lt;&lt; productSales[ 1 ] Sheet1 Page 2 for ( int j = 2 j &lt; PRODUCTS cout &lt;&lt; setw( 10 ) &lt;&lt; productSales[ j ] cout &lt;&lt; endl return 0 } Sheet1 Page 3 ++i ) { ++j ) { Sheet1 Page 4 ++j )...
View Full Document

Page1 / 4

Lee_assig25 - &amp;amp;lt;&amp;amp;lt; &amp;amp;quot;are...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online