Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.225.195.153
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/prog3.cpp
//***************************************
// Programming Assognment 3             *
//                                      *
//                                      *
//                                      *
// Written By Paula S. Woodson          *
// October 22, 2008                     *
//***************************************

// Preprocessor directives

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

// Main function

int main()
{

// --- Declare variables here

int
  amtordered,
  distance,
  concretecount = 0,
  rockcount = 0,
  sandcount = 0,
  topsoilcount = 0,
  totalcount =0,
  rejectedcount = 0;
  
float
  unitcost,
  mincharge,
  maxcharge,
  totalcharge =0,
  costofmaterials,
  costofdelivery,
  salestax,
  total;
  
char
  productch,
  dummych,
  classch;
bool
   errorincodes;   // false if codes okay, true if either code invalid

// --- Output report headings here
cout << "\n                              VWC Stone Mart, Inc.   ";
cout << "\n                                Order Summary      ";
cout << "\n                                           Cost of     Cost of                     ";
cout << "\n Product   Class    Amount    Distance    Materials    Delivery    Sales Tax   Total ";
  


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

totalcount ++;
   // --- 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;
           rejectedcount ++;
         }
      break;
      case 'R':
        switch (classch)
        {
         case 'C':
          unitcost = 22.25;
          rockcount ++; 
         break;
         case 'G':
          unitcost = 16.50;
          rockcount ++;
          break;
         case 'D':
          unitcost = 35.00;
          rockcount ++;
          break;
         default:
          errorincodes = true;   
          rejectedcount ++; 
       }
      break;
      case 'S':
        switch (classch)
        {
         case ' ':
          unitcost = 4.35;
          sandcount ++;
          break;
         default:
           errorincodes = true;
           rejectedcount ++;
        }
      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;
         default:
     
       errorincodes = true;
       rejectedcount ++;
     
      break;


    }







   // --- now handle detail line

   if (errorincodes)  // codes invalid - no calcs necessary - detail line with error mesg
   {
    cout <<"\n" <<  productch << setw(12) << classch << setw(12) << amtordered << setw(12) << distance<< setw(12);
    cout <<"    ***************** Error****************";


   }
   else               // codes valid - calcs, collect summary data, normal detail line
   {
    cout<< fixed << setprecision(2);
    costofmaterials = unitcost * amtordered;
    if (distance <5) 
       costofdelivery = .015 * costofmaterials;
      else if ((distance >= 5)&&(distance <15))
       costofdelivery = .02 * costofmaterials;  
      else if (distance >=15) 
       costofdelivery = .025 * costofmaterials;
    salestax = .05 * costofmaterials;
    costofmaterials = static_cast<int>(costofmaterials * 100 + .5)/100.0;
    costofdelivery = static_cast<int>(costofdelivery * 100 + .5)/100.0;
    salestax = static_cast<int>(salestax * 100 + .5)/100.0;
    total = costofmaterials + costofdelivery + salestax;
    if (total > maxcharge)
        maxcharge = total;
    if (total < mincharge)
        mincharge = total;
    totalcharge += total;
   cout <<"\n" <<  productch << setw(12) << classch << setw(12) << amtordered << setw(12) << distance << setw(12);
   cout << costofmaterials << setw(12)  << costofdelivery << setw(12) << salestax << setw(12) << total;
    
    


   }   // end of else 

   cin >> productch;  // get next product code

}  // end of processing while loop

// --- Now display summary statistics 

cout <<"\n\n                Summary                  "   ;
cout <<"\nTotal number of orders:" << totalcount <<"\n";
cout <<"\nReady-mix concrete:   " << concretecount <<"\n";
cout <<"\nRock and gravel:      " << rockcount <<"\n";
cout <<"\nSand:                 " << sandcount <<"\n";
cout <<"\nTopsoil:              " << topsoilcount <<"\n";
cout <<"\nRejected:             " << rejectedcount <<"\n";
cout <<"\n\nTotal charges: $" << totalcharge << setw(4)<<"\n";
cout <<"\nMinimum charges: $" << mincharge   << setw(4)<<"\n";
cout <<"\nMaximum charges: $" << maxcharge   << setw(4)<<"\n";



return 0;

}



Stv3n404 - 2023