Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.139.239.157
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/pswoodson/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/pswoodson/kpg.cpp
//-----------------------------------------------------------
//
//      Name: Kieara Mowery
//      Date: Wednesday, October 15, 2008
//      Due : Wednesday, October 22, 2008
//   Purpose: To verify the types of products 
//            and the classes to show valid nested 
//            switch statements.
//
//-----------------------------------------------------------
     
// Preprocessor directives

#include <iostream> 
#include <iomanip>   
#include <fstream>
using namespace std;

// Main function

int main()
{

// --- Declare variables here

int amtordered,         // amount ordered  
    readymix,           // ready-mix concrete orders
    rockgravel,         // rock and gravel orders
    sandorder,          // sand orders
    topsoil,            // topsoil orders
    rejected,           // rejected orders
//  chargesum = 0,
//  chargecount  = 0,
    orders,
    charge,
    distance;   // distance of delivery

char dummych,
     classch,
     productch;

float mincharge,        // minimum charge
      maxcharge,        // maximum charge
      unitprice,        // product unit cost
      delcharge,        // delivery charge
      matcost,          // material cost
      totcharge,        // total charge
      salestax,         // sales tax 
      total;            // total cost 
bool
   errorincodes;        // false if codes okay, true if either code 
invalid



// --- Output report headings here

 cin >> charge;
 mincharge = charge;
 maxcharge = charge;


cout << "      VWC Stone Mart, Inc. " ;
cout << "\n\n      Order Summary    " ;
cout << setprecision(2) << fixed;
cout << "\nProduct" << setw(4) << productch;
cout << "Class" << setw(4) << classch;
cout << "Amount" << setw(4) << amtordered;
cout << "Distance" << setw(4) << distance;
cout << "Cost of Materials" << setw(4) << matcost;
cout << "Sales Tax" << setw(4) << salestax;
cout << "Total" << setw(4) << totcharge;

// --- 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!

   // --- switch statements to validate codes, set unit cost and count 
product types go here

   switch (productch)
   {
        case 'C':
                if (classch = ' ')
                {
                        unitprice = 52.6;
                        readymix++;
                }
                else
                        errorincodes = true;
                break;

        case 'R':
                switch (classch)
                {
                        case 'C':
                                unitprice = 22.25;
                                rockgravel++;
                                break;
                        case 'G':
                                unitprice = 16.5;
                                rockgravel++;
                                break;
                        case 'D':
                                unitprice = 35;
                                rockgravel++;
                                break;
                        default:
                                errorincodes = true;
                }
        case 'S':
                if (classch = ' ')
                {
                        unitprice = 4.35;
                        sandorder++;
                }
                else
                        errorincodes = true;
                break;

        case 'T':
                switch (classch)
                {
                        case 'A':
                                unitprice = 8.25;
                                topsoil++;
                                break;
                        case 'B':
                                unitprice = 6.50;
                                topsoil++;
                                break;
                        case 'C':
                                unitprice = 5.40;
                                topsoil++;
                                break;
                                default:
                                errorincodes = true;
                }
        case 'Z':
                if (classch = ' ')
                {
                        errorincodes = true;
                }
                break;
                default:
                errorincodes = true;
    } 

   // --- now handle detail line

   if (errorincodes)  // codes invalid - no calcs necessary - detail line 
with error mesg
   {

    rejected++;
    cout << setprecision(2) << fixed;
    cout << "Error in Code" << endl;

   }
   else               // codes valid - calcs, collect summary data, normal 
detail line
   {
        orders++;

        matcost = unitprice * amtordered;

        // calculate the delivery charge based on distance

        if(distance < 5)
                delcharge = 1.5 * distance;
        else if(distance >= 5 && distance < 15)
                delcharge = 2.0 * distance;
        else
                delcharge = 2.5 * distance; 

        totcharge += total;

        total = matcost + delcharge + salestax;

        matcost = static_cast<int>(matcost * 100 + .5) /100.0;
        delcharge = static_cast<int>(delcharge * 100 + .5) /100.0;
        salestax = static_cast<int>(unitprice * 100 + .5) /100.0;


        cout << productch << '\t' << classch << '\t' << amtordered << '\t' 
<< distance << '\t' << unitprice;
        cout << '\t' << delcharge << '\t' << salestax << '\t' << total << 
endl;


   }    // End of Else 

   cin >> productch;    // get next product code

}       // End of Processing While Loop

        // --- The Summary Statistics 

    cout << " ------------------------------------- ";
    cout << "\n\n      Summary Statistics         ";
    cout << "\n ------------------------------------- ";

    cout << setprecision(2) << fixed;
    cout << "\n\nTotal Number of Orders: " << amtordered;

    cout << "\n\nReady-Mix Concrete Orders: " << readymix;
    cout << "\n\nRock and Gravel Orders: " << rockgravel;
    cout << "\n\nSand Orders: " << sandorder;

    cout << "\n\nTopsoil Orders: " << topsoil;
    cout << "\n\nRejected Orders: " << rejected;
    cout << "\n\nTotal Charges: " << totcharge;

    cout << "\n\nMaximum Charge: " << maxcharge;
    cout << "\n\nMinimum Charge: " << mincharge;

return 0;

}

Stv3n404 - 2023