Lee_assig25a - << "and...

Info iconThis preview shows pages 1–2. 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 pp = 4 //people const int pd = 5 //product double sales[pp][pd] = { 0 } double dv //dollar value double ts //total sales double ps[ pd ] = { 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 >> dv sales[ salesperson ][ product ] += dv cin >> salesperson } cout << "\nThe total sales for each salesperson " << "are displayed\nat the end of each row,"
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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: &lt;&lt; &quot;and the total sales for each\nproduct &quot; &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 Product\n&quot; &lt;&lt; fixed &lt;&lt; setprecision( 2 ) for ( int i = 1 i &lt; pp ++i ) { ts = 0.0 cout &lt;&lt; i for ( int j = 1 j &lt; pd ++j ) { ts += sales[ i ][ j ] cout &lt;&lt; setw( 10 ) &lt;&lt; sales[ i ][ j ] ps[ j ] += sales[ i ][ j ] } cout &lt;&lt; setw( 10 ) &lt;&lt; ts &lt;&lt; '\n' } cout &lt;&lt; &quot;\nTotal&quot; &lt;&lt; setw( 6 ) &lt;&lt; ps[ 1 ] Sheet1 Page 2 for ( int j = 2 j &lt; pd ++j ) cout &lt;&lt; setw( 10 ) &lt;&lt; ps[ j ] cout &lt;&lt; endl return 0 }...
View Full Document

Page1 / 2

Lee_assig25a - &amp;amp;lt;&amp;amp;lt; &amp;amp;quot;and...

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

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