Server IP : 172.16.15.8 / Your IP : 3.147.65.47 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/vnlaughlin/../jljustice/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
//---------------------------------------------------- // Programming Assignment #3: VWC Stone Mart - // Written By: Jared Justice - // Due Date: October 22, 2008 - // - // Purpose: To determine the total costs of - // purchased materials. Also to calculate - // the amount of sales throughtout the day.- //---------------------------------------------------- // Preprocessor directives #include <iostream> #include <iomanip> #include <fstream> using namespace std; // Main function int main() { // --- Declare variables here int distance, // distance of delivery totorders = 0, // total count of orders readymorders = 0, // number of ready-mix orders rockorders = 0, // number of rock and gravel orders sandorders = 0, // number of sand orders topsoilorders = 0, // number of topsoil orders rejectorders = 0, // number of rejected orders amtordered; // amount of materials ordered float unitcost, // cost of materials totalcharg =0, // sum of total charges salestax, // sales tax delivcost, // cost of the delivery costmats, // cost of the materials maxcharge, // maximum charge mincharge, // minimum charge total; // total of charges char dummych, // skips blank in column 2 classch, // the class type productch; // the product type bool errorincodes; // false if codes okay, true if either code invalid // --- Output report headings here cout << "\n ----------------------------------------------------------------------------------------------- "; cout << "\n VWC Stone Mart, Inc. "; cout << "\n\n Order Summary "; cout << "\n ----------------------------------------------------------------------------------------------- "; cout << "\nProduct Class Amount Distance Cost Of Cost Of Sales Tax Total"; cout << "\n Mateials Delivery "; // --- 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') { 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! totorders++; // --- switch statements to validate codes, set unit cost and count product types go here switch (productch) { case 'C': switch (classch) { case ' ': unitcost = 52.60; readymorders++; break; default: errorincodes = true; break; } break; case 'R': switch (classch) { case 'C': unitcost = 22.25; rockorders++; break; case 'G': unitcost = 16.50; rockorders++; break; case 'D': unitcost = 35.00; rockorders++; break; default: errorincodes = true; break; } break; case 'S': switch (classch) { case ' ': unitcost = 4.35; sandorders++; break; default: errorincodes = true; break; } break; case 'T': switch (classch) { case 'A': unitcost = 8.25; topsoilorders++; break; case 'B': unitcost = 6.50; topsoilorders++; break; case 'C': unitcost = 5.40; topsoilorders++; break; default: errorincodes = true; break; } break; } // --- now handle detail line if (errorincodes) // codes invalid - no calcs necessary - detail line with error mesg { rejectorders++; cout << "\n\n" << setw(4) << productch << "\t" << setw(4) << classch << "\t " << setw(4); cout << amtordered << "\t " << setw(4) << distance; cout << "\t********************* Error ****************************"; cout << endl; } else // codes valid - calcs, collect summary data, normal detail line { costmats = (amtordered * unitcost); costmats = static_cast<int>(costmats * 100 + .5)/100.0; salestax = costmats * 0.05; salestax = static_cast<int>(salestax * 100 + .5)/100.0; if (distance < 5) delivcost = costmats * 0.015; else if (distance < 15) delivcost = costmats * 0.020; else if (distance >= 15) delivcost = costmats * 0.025; delivcost = static_cast<int>(delivcost * 100 + .5)/100.0; total = costmats + delivcost + salestax; totalcharg += total; if(total > maxcharge) maxcharge = total; if(total < mincharge) mincharge = total; cout << endl; cout << " " << setw(2) << productch << " \t " << setw(2) << classch << " \t " << setw(2); cout << amtordered << " \t " << setw(2) << distance; cout << " \t $ " << setw(5) << costmats << " \t$ " << setw(5) << delivcost << " \t$ " << setw(5); cout <<salestax << " \t$" << setw(7) << total; cout << endl; } // end of else cin >> productch; // get next product code } // end of processing while loop // --- Now display summary statistics cout << "\n"; cout << "\n Summary"; cout << "\n\n"; cout << " Total Number of Orders: " << totorders; cout << "\n Ready-Mix Concrete: " << readymorders; cout << "\n Rock and Gravel: " << rockorders; cout << "\n Sand: " << sandorders; cout << "\n Topsoil: " << topsoilorders; cout << "\n Rejected: " << rejectorders; cout << endl; cout << endl; cout << " Total Charges: $" << setw(5) << totalcharg; cout << "\n Minimum Charge: $" << setw(6) << mincharge; cout << "\n Maximum Charge: $" << setw(5) << maxcharge; return 0; }