Server IP : 172.16.15.8 / Your IP : 13.59.205.182 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/dobutler/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// Outline for Programming Assignment #3 // Preprocessor directives #include <iostream> #include <iomanip> #include <fstream> using namespace std; // Main function int main() { // --- Declare variables here int concretecount, rockcount, sandcount, topcount, float unitprice, matcost, salestax, dcharge, total; bool errorincodes; // false if codes okay, true if either code invalid // --- Output report headings here cout << " VWC Stone Mart, Inc. "; cout << "\n Order Summary "; cout << "\n Cost of Cost of "; cout << "\n Product Class Amount Distance Materials Delivery "; cout << " Sales Tax Total "; // --- Set numeric formatting for detail lines cout << fixed << setprecision(2); // --- Initialize counters, summary variables here concretecount = 0; rockcount = 0; sandcount = 0; topcount = 0; mincharge = 1e29; maxcharge = 0; // --- Prime loop with first input value cin >> productch; // --- Processing loop - stops when product code is sentinel 'Z' while (productch != 'Z') { cin.get(dummych); // skip blank in column 2 cin.get(classch); // get char in column 3, even if blank cin >> amtordered >> distance; // remainder of input in normal fashion errorincodes = false; // set flag - no error found yet! // --- switch statements to validate codes, set unit cost and count product types go here switch (productch) { case 'C': switch (classch) { case ' ': unitprice = 52.60; concretecount ++; break; default: errorincodes = true; } break; case 'R': switch (classch) { case 'C': unitprice = 22.25; rockcount ++; break; default: errorincodes = true; case 'G': unitprice = 16.50; rockcount ++; break; default: errorincodes = true; case 'D': unitprice = 35.00 rockcount ++; break; defualt: errorincodes = true; } case 'S' switch (classch) { case ' ': unitprice = 4.35 sandcount ++; break; default: errorincodes = true; } case 'T' switch (classch) { case 'A': unitprice = 8.25 topcount ++; break; default: errorincodes = true; case 'B': unitprice = 6.50 topcount ++; break; default: errorincodes = true; case 'C': unitprice = 5.40 topcount ++; break; default: errorincodes = true; } } // --- now handle detail line if (dcharge < 5); { dcharge = .015; else if (dcharge >= 5 || < 15) dcharge = .02; else dcharge = .025; } if (errorincodes) // codes invalid - no calcs necessary - detail line with error mesg { case 'C' = false; case 'R' = false; case 'S' = false; case 'T' = false; } else // codes valid - calcs, collect summary data, normal detail line { case 'C' = (52.60 * concretecount) + (52.60 * dcharge) + (52.60 * .05) case 'R' = } // end of else cin >> productch; // get next product code } // end of processing while loop // --- Now display summary statistics return 0; }