Hello Everyone,
I am having trouble all lweek trying to figure how to ask the user to input product number, total of sale, and -1 to end input which should do the math. I made it to this point on my own (accually from the book redone and I understand this part well) but I don't know where to start the second stage of this program. Please forgive me for any bad indentations. I have to write it this way so I can see where Im going until completed. This program works to a certain point. I can do the math but I don't have it corrected here yet. It add the size of the column to the total for some strange reason. I had a great start with this one and just knew I could do it, but I cannot
Thanks in advance
Code:#include <string> // for .h #include <iostream> #include <iomanip>// parameterized stream manipulators using namespace std; // .................... // .................... .h // .................... class definition class Constructor0 { public: // constants static const int ROW_S = 4;// number of Salesmen static const int COLUMN_S = 5;// number of column (numbers or SALES) // constructor initializes company name and array groups Constructor0( string, const int [][ COLUMN_S ] ); void setName( string ); string getSubLine(); void printMessage(); void process_ARRAYS(); int getMinimum(); int getMaximum(); double getTOTAL_0( const int [], const int ); void bar_Chart_1(); void output_M_N(); private: string subName;// sub name for this group int _M_N[ ROW_S ][ COLUMN_S ];// two-dimensional array of _M_N }; // .................... // .................... cpp // .................... Member-function definitions // two-argument constructor initializes subName and arrayList Constructor0::Constructor0( string name, const int array1[][ COLUMN_S ] ) { setName( name ); for ( int rows = 0; rows < ROW_S; rows++ )// copy array1 info for ( int j = 0; j < COLUMN_S; j++ ) _M_N[ rows ][ j ] = array1[ rows ][ j ]; } /////// /////// void Constructor0::setName( string name ) { subName = name; } /////// /////// string Constructor0::getSubLine() { return subName; } /////// /////// void Constructor0::printMessage() { cout << endl; cout << "Enter the salesperson ( 1 - 4 ), product number ( 1 - 5 ),\ and total sales" << endl << getSubLine() << "." << endl; } ///////// ///////// ///////// ///////// ///////// ///////// perform various operations on the data ///////// void Constructor0::process_ARRAYS() { output_M_N(); // call output-_M_N-array // << "\nHighest grade in the grade book is " << getMaximum() << endl; } /////////pass row of _M_N and the value of SALES ///////// determine TOTAL_0 ///////// double Constructor0::getTOTAL_0( const int setOf_ARRAYS[], const int COL ) { int total = 0; for ( int j = 0; j < COL; j++ )// add each column context total += setOf_ARRAYS[ j ]; // return static_cast< double >( total ) + _M_N; return double( total ) + COL;// return averages } ///////// ///////// output the contents of the _M_N array ///////// void Constructor0::output_M_N() { cout << "\nThe _M_N are:\n\n"; cout << " ";// align column heads. // Create col heading for ( int j = 0; j < COLUMN_S; j++ )// for each (_5) col cout << " Item-" << j + 1 << " ";// Main col heading cout << " Total" << endl;// col heading at end // create rows/cols of // text representing array // _M_N. (_5) rows. for ( int rows = 0; rows < ROW_S; rows++ ) { cout << "SP-" << rows + 1; for ( int j = 0; j < COLUMN_S; j++ )// out stud sales cout << setw( 10 ) << _M_N[ rows ][ j ] << ".00";// inside of table //cout << setw( 10 ) << setprecision( 2 ) << fixed << TOTAL_0 << endl; // call member function getTOTAL_0 to calculate saleperson's (row) TOTAL_0; // pass row of _M_N and the value of SALES as the arguments // Push last column right = 9 -- 84.33 double TOTAL_0 = getTOTAL_0( _M_N[ rows ], COLUMN_S ); cout << setw( 9 ) << setprecision( 2 ) << fixed << TOTAL_0 << endl; } // end outer for } // .................... // .................... cpp // .................... int main() { // two-dimensional array of saleperson (row) _M_N int array1[ Constructor0::ROW_S ][ Constructor0::COLUMN_S ] = { { 100, 0, 500, 0, 0 }, { 0, 200, 0, 500, 600 }, { 0, 50, 500, 0, 750 }, { 0, 0, 0, 60, 70 } }; Constructor0 myMulti_2D( "Enter -1 for the salesperson to end input.", array1 ); myMulti_2D.printMessage(); // cin >> array1[i][j]; myMulti_2D.process_ARRAYS(); cout << endl; cout << endl; system("pause"); system ("CLS"); return main(); }



LinkBack URL
About LinkBacks





