Server IP : 172.16.15.8 / Your IP : 18.221.183.34 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/cchansen/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// ------------------------------------------------------------------------------- // Programming Assignment #3: VWC Stone Mart, Inc. Summary and Analysis // // Written by Caitlin Hansen // October 2008 // // Purpose: To calculate the cost of materials, cost of delivery, sales tax, and // total charges for the orders, total number of orders, number of the various // materials orders, number of rejected orders, minimum charge, and maximum charge. // ------------------------------------------------------------------------------- // ------- Preprocessor directives #include <iostream> #include <iomanip> #include <fstream> using namespace std; // ----------- Main Function ------------ int main() { // ------------ Variables int distance, // the distance for delivery totalorders, // the total number of orders concretecount, // the amount of ready-mix concrete orders gravelcount, // the amount of rock and gravel orders sandcount, // the amount of sand orders topsoilcount, // the amount of topsoil orders rejectcount, // the amount of rejected orders ordercount, // the amount of cubic yards ordered amtordered; // the amount of product ordered float unitcost, // the price of the products per cubic yard deliverychrge, // the price of the delivery of the product(s) mincharge, // the minimum charge of the total cost maxcharge, // the maximum charge of the total cost matscost, // the cost of the product only salestax, // the total charge of the sales tax totalcharge; // the total charge of entired purchase char productch, // the product code C, R, S, or T dummych, // skip blank in column 2 classch; // the class code C, G, D, A, B, or C bool errorincodes; // false if codes okay, true if either code invalid // --- Output report headings here cout << endl; cout << "------------------------------------------------------------------------------"; cout << endl; cout << " VWC Stone Mart, Inc. "; cout << endl; cout << " Order Summary "; cout << endl; cout << "------------------------------------------------------------------------------"; cout << endl; cout << endl; cout << "------------------------------------------------------------------------------"; cout << " Cost of Cost of "; cout << endl; cout << "Product Class Amount Distance Materials Delivery Sales Tax Total"; cout << endl; // --- Set numeric formatting for detail lines cout << fixed << setprecision(2); // --- Initialize counters, summary variables here mincharge = 1e29; maxcharge = 0; // --- Prime loop with first input value cin >> productch; // --- Processing loop - stops when product code is sentinel 'Z' while (productch != 'Z') { while (unitcost >= 0) { if (unitcost > maxcharge) maxcharge = unitcost; if (unitcost < mincharge) mincharge = unitcost; } 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': cout << "C"; switch(classch) { case ' ': unitcost = 52.60; concretecount = totalorders; break; default: errorincodes = true; } break; case 'R': gravelcount = totalorders; cout << "R"; switch(classch) { case 'C': unitcost = 22.25; cout << "C"; break; case 'G': unitcost = 16.50; cout << "G"; break; case 'D': unitcost = 35.00; cout << "D"; break; default: errorincodes = true; } break; case 'S': sandcount = totalorders; cout << "S"; switch(classch) { case ' ': unitcost = 4.35; break; default: errorincodes = true; } break; case 'T': topsoilcount = totalorders; cout << "T"; switch(classch) { case 'A': unitcost = 8.25; cout << "A"; break; case 'B': unitcost = 6.50; cout << "B"; break; case 'C': unitcost = 5.40; cout << "C"; break; default: errorincodes = true; } break; } // --- now handle detail line if (errorincodes) // codes invalid - no calcs necessary - detail line with error mesg { cout << "---------------------- Error - Invalid Codes ----------------------"; } else // codes valid - calcs, collect summary data, normal detail line { amtordered ++; matscost = amtordered * unitcost; matscost = static_cast<int>(matscost * 100.0 + .5)/100.0; if (distance < 5) deliverychrge = matscost * 0.015; else if (distance > 5 && distance < 15) deliverychrge = matscost * 0.020; else if (distance > 15) deliverychrge = matscost * 0.025; deliverychrge = static_cast<int>(deliverychrge * 100.0 + .5)/100.0; totalcharge = matscost + deliverychrge + salestax; totalorders += amtordered; } // end of else cin >> productch; // get next product code } // end of processing while loop // --- Now display summary statistics cout << endl; cout << " " << productch; cout << endl; cout << " " << classch; cout << endl; cout << " " << ordercount; cout << endl; cout << " " << distance; cout << endl; cout << " " << matscost; cout << endl; cout << " " << deliverychrge; cout << endl; cout << " " << salestax; cout << endl; cout << " " << totalcharge; cout << endl; return 0; }