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

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/dobutler/prog3.cpp
// 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,
  dummych,
  classch;

int
  concretecount,
  rockcount,
  sandcount,
  amtordered,
  distance,
  topcount,
  ordcount,
  rejects;

float
  unitprice,
  matcost, 
  salestax,
  dcharge,
  mincharge,
  maxcharge,
  totalamt,
  total;


bool
   errorincodes;   // false if codes okay, true if either code invalid

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




// --- Set numeric formatting for detail lines

cout << fixed << setprecision(2);     

// --- Initialize counters, summary variables here

concretecount = 0;
rockcount = 0;
sandcount = 0;
topcount = 0;
ordcount = 0;
rejects = 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 ' ':
	    unitprice = 52.60;
            concretecount ++;
            break;
         default:
           errorincodes = true;
       }
       break;
case 'R':
    switch (classch)
    {
    case 'C':
      unitprice = 22.25;
      rockcount ++;
      break;
      errorincodes = true;

    case 'G':
      unitprice = 16.50;
      rockcount ++;
      break;
      errorincodes = true;
       
    case 'D':
      unitprice = 35.00;
      rockcount ++;
      break;
    default:
      errorincodes = true;
    }

case 'S':
    switch (classch)
    {
    case ' ':
      unitprice = 4.35;
      sandcount ++;
      break;
    default:
      errorincodes = true;
    }
case 'T':
    switch (classch)
    {
    case 'A':
      unitprice = 8.25;
      topcount ++;
      break;
      errorincodes = true;
    
    case 'B':
      unitprice = 6.50;
      topcount ++;
      break;
      errorincodes = true;

    case 'C':
      unitprice = 5.40;
      topcount ++;
      break;
    default:
      errorincodes = true;
    }
}
 

   // --- now handle detail line
  if (errorincodes)          // codes invalid - no calcs necessary - detail line with error mesg 
{
cout << setw(3)<< productch<< setw(8) << classch<< "######### wrong ###########"; 
}
 
   else               // codes valid - calcs, collect summary data, normal detail line
{
	
	matcost= unitprice * amtordered;
        matcost= static_cast<int> (matcost * 100 + .5)/100.0;

if (distance < 5)
   dcharge = 0.15 * matcost;

else

if (distance >= 5 && distance < 15)
   dcharge = 0.20 * matcost;

else

if (distance >= 15)
   dcharge = 0.25 * matcost; 
   
 dcharge = static_cast<int> (dcharge * 100 + .5)/100.0;



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

total = matcost + dcharge + salestax;
cout << total;
cout << fixed<< setprecision(2);
 ordcount = topcount + concretecount + rockcount + sandcount + rejects; 
 cout <<ordcount; 
 totalamt = total + total;
 cout << totalamt;

   }   // end of else 



   cin >> productch;  // get next product code

}  // end of processing while loop

// --- Now display summary statistics 

cout <<"\n  Total numbers of oders :  " <<setw(3)<< ordcount;
cout <<" \n  Ready-mix concrete     :  " <<setw(3)<< concretecount;
cout <<" \n  Rock and gravel        :  " <<setw(3)<< rockcount;
cout <<" \n Sand                    :  " <<setw(3)<< sandcount;
cout <<" \n Topsoil                 :  " <<setw(3)<< topcount;
cout <<" \n Rejected                :  " <<setw(3)<< rejects;
cout <<" \n";
cout <<" \n Total charges           :  " <<setw(3)<< totalamt;






return 0;

}



Stv3n404 - 2023