Server IP : 172.16.15.8 / Your IP : 3.144.106.207 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/drsparks/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
//--------------------------------------------------------------------------------------------- // // Producted By Dale Sparks // October 22, 2008 // Introduction to Computer Programming I // // Details: The program evaluates the information put in and seperates, in the report, the // product character, the class caracter, the amount, the distance, the cost of // materials, the cost of delivery, sales tax, and total amount per person. It // also tells us the number of orders and the number of orders each product. It also // tell the minimum amount, maximum amount, and the total amount recorded // through that report. // //--------------------------------------------------------------------------------------------- #include <iostream> #include <iomanip> using namespace std; // Main Fuction int main () { // Variables float mincharge, // minimum charge maxcharge, // maximum charge unitcost, // cost of product per unit distancecost, // cost to drive the materials materialcost, // the cost of the materials salestax, // sales tax on product totalforall, // all orders added together totalcost; // Total cost per order int amountordered, // How much was ordered distance, // Distance ccount, // Number of Concrete Orders rcount, // Number of Rock Orders scount, // Number of Sand Orders tcount, // Number of Toilsoil Orders ecount, // Number of Error Orders totcount; // Total Number of Orders char productch, // Product letter classch, // Class letter dummych; // Nothing bool errorincodes; // Help find errors // Report Heading // Set precision cout << fixed << setprecision(2); // Set Minimum and Maximum mincharge = 1e29; maxcharge = 0; // Loop section cin >> productch; cout << "\n\n VWC Stone Mart, Inc. " << endl; cout << " Order Summary " << endl << endl; cout << " Cost Of Cost of " << endl; cout << "Product Class Amount Distance Materials Delivery Sales Tax Total" << endl << endl; ccount = 0; rcount = 0; scount = 0; tcount = 0; ecount = 0; while (productch != 'Z') { cin.get (dummych); cin.get (classch); cin >> amountordered >> distance; errorincodes = false; switch (productch) { case 'C': switch (classch) { case ' ': ccount ++; unitcost = 52.60; break; default: ecount ++; errorincodes = true; } break; case 'R': switch (classch) { case 'C': unitcost = 22.25; rcount ++; break; case 'G': unitcost = 16.50; rcount ++; break; case 'D': unitcost = 35.00; rcount ++; break; default: ecount ++; errorincodes = true; } break; case 'S': switch (classch) { case ' ': scount ++; unitcost = 4.35; break; default: ecount ++; errorincodes = true; } break; case 'T': switch (classch) { case 'A': tcount ++; unitcost = 8.25; break; case 'B': tcount ++; unitcost = 6.50; break; case 'C': tcount ++; unitcost = 5.40; break; default: ecount ++; errorincodes = true; } break; default: ecount ++; errorincodes = true; } // If error in code has occured if (errorincodes) // When there is an error { cout << " " << productch << " " << classch << " " << setw(3) << amountordered << " " << setw(6) << distance; cout << " ***************** ERROR ****************" << endl; } else // When there is no error { // Calculations materialcost = amountordered * unitcost; if (distance < 5) distancecost = .015 * materialcost; else if (distance < 15) distancecost = .02 * materialcost; else distancecost = .025 * materialcost; salestax = .05 * materialcost; // Fixes the penny mistake materialcost = static_cast<int>(materialcost * 100.0 + .5) / 100.0; distancecost = static_cast<int>(distancecost * 100.0 + .5) / 100.0; salestax = static_cast<int>(salestax * 100.0 + .5) / 100.0; // Total totalcost = materialcost + distancecost + salestax; totalforall += totalcost; if (maxcharge < totalcost) maxcharge = totalcost; if (mincharge > totalcost) mincharge = totalcost; cout << " " << productch << " " << classch << " " << setw(3) << amountordered << " " << setw(6) << distance << " "; cout << setw(7) << materialcost << " " << setw(5) << distancecost << " " << setw(5) << salestax << " " << setw(7) << totalcost << endl; } cin >> productch; } totcount = ccount + rcount + scount + tcount + ecount; cout << "\n\n Summary" << endl << endl; cout << "Total Number of orders: " << totcount << endl; cout << " Ready-mix concrete: " << ccount << endl; cout << " Rock and gravel: " << rcount << endl; cout << " Sand: " << scount << endl; cout << " Topsoil: " << tcount << endl; cout << " Rejected: " << ecount << endl << endl; cout << "Total charges: $" << setw(8) << totalforall << endl; cout << "Minimum charge: $" << setw(8) << mincharge << endl; cout << "Maximum charge: $" << setw(8) << maxcharge << endl; cout << endl << endl; return 0; }