25 - } cout << totalSales...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 #include <iostream> using namespace std int main() { const int PEOPLE = 5 const int PRODUCTS = 6 double sales[PEOPLE][PRODUCTS] = { 0 } double value double totalSales double productSales[ PRODUCTS ] = { 0 } int salesperson int product cout << "Enter the salesperson (1-4), " << "product number (1-5)\nand total sales." << "Enter -1 for the salesperson to end 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 " << "are displayed at the bottom of each column.\n" for ( int i = 1 i < PEOPLE ++i ) { totalSales = 0 t cout << i c for ( int j = 1 j < PRODUCTS ++j ) { totalSales += sales[ i ][ j ] t cout<< sales[ i ][ j ] productSales[ j ] += sales[ i ][ j ]
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: } cout &lt;&lt; totalSales &lt;&lt; '\n' } cout &lt;&lt; &quot;\nTotal&quot; &lt;&lt; productSales[ 1 ] c for ( int j = 2 j &lt; PRODUCTS ++j ) cout &lt;&lt; productSales[ j ] cout &lt;&lt; endl return 0 } _____________________________________________________________ #include &lt;iostream&gt; using namespace std Sheet1 Page 2 int main() { int i, j, a, b const int salesperson = 4 const int products = 5 int sales[salesperson][products] for (i = 1 i &lt; salesperson i++) { for (j = 1 j &lt; products j++) { cout &lt;&lt; &quot;Input salesperson's number: &quot; cin &gt;&gt; sales[i][j] cout &lt;&lt; &quot;Input product number: &quot; cin &gt;&gt; sales[i][j] cout &lt;&lt; &quot;Input total value of that product sold that day: &quot; cin &gt;&gt; sales[i][j] } } cout &lt;&lt; &quot;Summary Table&quot; for (a=1 a&lt;5 a++) { cout &lt;&lt; &quot;Product &quot; &lt;&lt; a } cout &lt;&lt; &quot;Total \n&quot; for (b=1 b&lt;6 b++){ cout &lt;&lt; &quot;Salesperson &quot; &lt;&lt; b &lt;&lt; endl } cout &lt;&lt; &quot;Total &quot; return 0 }...
View Full Document

Page1 / 2

25 - } cout &amp;amp;lt;&amp;amp;lt; totalSales...

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