Server IP : 172.16.15.8 / Your IP : 3.142.198.51 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 = 0, // the total number of orders concretecount = 0, // the amount of ready-mix concrete orders gravelcount = 0, // the amount of rock and gravel orders sandcount = 0, // the amount of sand orders topsoilcount = 0, // the amount of topsoil orders rejectcount = 0, // the amount of rejected orders 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 = 0, // the total charge of entire purchase total; // the total charge of the individual 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 << endl; cout << " Cost of Cost of "; cout << endl; cout << " Product Class Amount Distance Materials Delivery Sales Tax Total "; cout << endl; cout << "-----------------------------------------------------------------------------------------------------"; 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') { totalorders++; 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 ' ': unitcost = 52.60; concretecount++; break; default: errorincodes = true; break; } break; case 'R': switch( classch ) { case 'C': unitcost = 22.25; gravelcount++; break; case 'G': unitcost = 16.50; gravelcount++; break; case 'D': unitcost = 35.00; gravelcount++; break; default: errorincodes = true; break; } break; case 'S': switch( classch ) { case ' ': unitcost = 4.35; sandcount++; break; default: errorincodes = true; break; } break; case 'T': switch( classch ) { case 'A': unitcost = 8.25; topsoilcount++; break; case 'B': unitcost = 6.50; topsoilcount++; break; case 'C': unitcost = 5.40; topsoilcount++; break; default: errorincodes = true; break; } break; } // --- now handle detail line if (errorincodes) // codes invalid - no calcs necessary - detail line with error mesg { cout << " " << productch << " \t " << classch << " \t\t " << amtordered; cout << " \t\t " << distance; cout << " ------------------- Error - Invalid Codes ------------------" << endl; rejectcount++; } else // codes valid - calcs, collect summary data, normal detail line { matscost = amtordered * unitcost; salestax = matscost * 0.05; if (distance <= 5) deliverychrge = matscost * 0.015; else if (distance < 15) deliverychrge = matscost * 0.020; else deliverychrge = matscost * 0.025; deliverychrge = static_cast<int>(deliverychrge * 100 + 0.5)/100.0; salestax = static_cast<int>(salestax * 100 + 0.5)/100.0; total = matscost + deliverychrge + salestax; if (total > maxcharge) maxcharge = total; if (total < mincharge) mincharge = total; totalcharge += total; matscost = static_cast<int>(matscost * 100 + 0.5)/100.0; cout << " " << productch << " \t\t " << setw(2) << classch << " \t " << setw(2) << amtordered; cout << " \t " << setw(2) << distance << " \t $ " << setw(5) << matscost; cout << " \t $ " << setw(5) << deliverychrge << " \t $ " << setw(5) << salestax; cout << " \t $ " << setw(5) << total << endl; } // end of else // get next product code cin >> productch; } // end of processing while loop // --- Now display summary statistics cout << endl; cout << endl; cout << " --------------------------------------------"; cout << endl; cout << " Summary "; cout << endl; cout << " --------------------------------------------"; cout << "Total number of orders: " << totalorders << endl; cout << "Ready-Mix Concrete: " << concretecount << endl; cout << "Rock & Gravel: " << gravelcount << endl; cout << "Sand: " << sandcount << endl; cout << "Topsoil: " << topsoilcount << endl; cout << "Rejected: " << rejectcount << endl; cout << endl; cout << endl; cout << "Total Charges: $ " << setw(4) << totalcharge << endl; cout << "Minimum Charge: $ " << setw(4) << mincharge << endl; cout << "Maximum Charge: $ " << setw(4) << maxcharge << endl; cout << endl; return 0; }