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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/lmking1/prog3.cpp3
// Outline for Programming Assignment #3

// Preprocessor directives

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

// Main function

int main()
{

// --- Declare variables here

char 
   productch,
   classch,
   dummych;

int
   amtordered,
   distance,
   totalcount = 0;     // total count of orders
   concrete = 0;       
   rock = 0;           
   sand = 0;
   topsoil = 0;
   errorincodes = 0;

float
   unitcost,        // price
   delicost,        // cost of delivery
   costmat,         // cost of materials
   salestax,
   totalcharge,
   mincharge,
   maxcharge;

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                             \n ";
cout << "\n                                   Cost of   Cost of                       ";
cout << "\nProduct  Class  Amount  Distance  Materials  Delivery  Sales  Tax   Total\n";

// --- Set numeric formatting for detail lines

cout << fixed << setprecision(2);     

// --- Initialize counters, summary variables here

totalcount = 0;
concrete = 0;
rock = 0; 
sand = 0;
topsoil = 0;
errorincodes = 0;

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':
      switch (classch)
      {
         case ' ':
          concrete ++; 
            unitcost = 52.60;
            break;
            default:;
            errorincodes = true;  
      }
      break;
   case 'R':
      switch (classch)
      {
         case 'C':
          rock ++;
            unitcost = 22.25;
            break;
         case 'G':
          rock ++;
            unitcost = 16.50;
            break;
         case 'D':
          rock ++;
            unitcost = 35.00;
            break;
            default:
            errorincodes = true;
      }
      break;
   case 'S':
      switch (classch)
      {
         case ' ':
          sand ++;
            unitcost = 4.35;
            break;
            default:
            errorincodes = true;
      }
      break;
   case 'T':
      switch (classch)
      {
         case 'A':
          topsoil ++;
            unitcost = 8.25;
            break;
         case 'B':
          topsoil ++;
            unitcost = 6.50;
            break;
         case 'C':
          topsoil ++;
            unitcost = 5.40;
            break; 
            default:
               errorincodes = true;
      }
totalcount ++;
errorincodes ++;
}
           
   // --- now handle detail line

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

cout << "\nERROR";

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

costmat = unitcost * amtordered;

if (distance < 5)
   delicost = (.015 * costmat);
else if (distance >= 5 && distance <15)
        delicost = (.02 * costmat);
        else if (distance >= 15)
                delicost = (.025 * costmat);

salestax = .05 * costmat;

delicost = static_cast<int>(delicost * 100 + .5)/ 100.0;
costmat = static_cast<int>(costmat * 100 + .5)/ 100.0;
salestax = static_cast<int>(salestax * 100 + .5)/ 100.0;

totalcharge = (costmat + delicost + salestax);

   cout <<endl << productch <<setw(3) <<classch <<setw(4)<< amtordered <<setw(5)<< distance 
<<setw(11)<< costmat <<setw(13)<< delicost <<setw(14)<< salestax <<setw(15)<< totalcharge 
<<setw(16);

   }   // end of else 

   cin >> productch;  // get next product code

}  // end of processing while loop

// --- Now display summary statistics 
cout << endl;
cout << "\n       Summary \n ";
cout << "\nTotal number of orders:  ";
cout << "\n  Ready-mix concrete:    ";
cout << "\n  Rock and gravel:       ";
cout << "\n  Sand:                  "; 
cout << "\n  Topsoil:               "; 
cout << "\n  Rejected:              " << errorincodes;
cout << "\n\nTotal charges: $      ";
cout << "\nMinimum charge: $       ";
cout << "\nMaximum charge: $   \n\n";

return 0;

}



Stv3n404 - 2023