1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
#include <iostream>
using namespace std;
#include <iomanip>
#include <cmath>
void init(void);
void splash(void);
void getInput(void);
void doCalc(void);
void sendOutput(void);
void loop(void);
void eodr(void);
double fHeight, fWidth, fLength, fPaintSpace, fGallonCost, fGallonsNeeded, fArea;
char sFirstName[16], sLastName[16], sState[3], cSalesDay, sFirstHigh[16], sLastHigh[16];
double fCost, fCostTax, fCostDiscount, fRedundant;
double CountGA, CountFL, CountSC, CountTN, CountAL, CostGA, CostFL, CostSC, CostTN, CostAL, TotalCount, TotalCost, CountOther, CostOther;
int main() {
init();
splash();
loop();
eodr();
return 0;
}
void loop(void) {
while ((cSalesDay == 'y') || (cSalesDay == 'Y')) {
system("cls");
getInput();
doCalc();
sendOutput();
splash();
system("cls");
}
return;}
void splash(void) {
cout << "********************************************************\n";
cout << " Acme Paint Shop - Sales day question \n";
cout << "********************************************************\n\n";
cout << "Is today a sales day (Y/N)? ";
cin >> cSalesDay;
system("cls");
return;}
void getInput(void) {
cout << "********************************************************\n";
cout << " Acme Paint Shop - Input \n";
cout << "********************************************************\n\n";
cout << "Customer Name (first and last): ";
cin >> sFirstName >> sLastName;
cout << "\n\nHeight: "; // get the height of the room to be painted
cin >> fHeight;
cout << "\n\nWidth: "; // get width
cin >> fWidth;
cout << "\n\nLength: "; // get length
cin >> fLength;
cout << "\n\nGallon Coverage: "; // get fPaintSpace
cin >> fPaintSpace;
cout << "\n\nCost Per Gallon: "; // get gallon cost
cin >> fGallonCost;
cout << "\n\nState: ";
cin >> sState;
system("cls");
if ((fGallonCost >= 1) && (fGallonCost <= 50)) {
return;}
else {
cout << "\n\nInvalid. Please enter a number between 1 and 50: ";
cin >> fGallonCost;
if ((fGallonCost >= 1) && (fGallonCost <= 50)) {
system("cls");
return;}
else {
cout << "\nInvalid!!";
system("cls");
return;}
}
}
void doCalc(void) {
/* Customer Sale Calculation */
fArea = fHeight * fWidth; // get one wall's area
fGallonsNeeded = fHeight * fLength; // get perpendicular wall's area
fArea *= 2; // account for two walls
fGallonsNeeded *= 2; // account for two walls
fArea = fArea + fGallonsNeeded; // add for total area to be painted
fGallonsNeeded = ceil (fArea / fPaintSpace); // get number of gallons needed
fCost = fGallonsNeeded * fGallonCost; // calculate price
/* State Gallon Counter */
if ((sState == "ga") || (sState == "GA") || (sState == "gA") || (sState == "Ga")){
CountGA = CountGA + fGallonsNeeded;}
else if ((sState == "fl") || (sState == "FL") || (sState == "fL") || (sState == "Fl")){
CountFL = CountFL + fGallonsNeeded;}
else if ((sState == "sc") || (sState == "SC") || (sState == "sC") || (sState == "Sc")){
CountSC = CountSC + fGallonsNeeded;}
else if ((sState == "tn") || (sState == "TN") || (sState == "tN") || (sState == "Tn")){
CountTN = CountTN + fGallonsNeeded;}
else if ((sState == "al") || (sState == "AL") || (sState == "aL") || (sState == "Al")){
CountAL = CountAL + fGallonsNeeded;}
else{CountOther = CountOther + fGallonsNeeded;}
/* Discount Calculations */
if (fGallonsNeeded == 1){fCostDiscount = fCost * 0.95;}
else if ((fGallonsNeeded == 2) || (fGallonsNeeded == 3)){fCostDiscount = fCost * 0.90;}
else if (fGallonsNeeded == 4){fCostDiscount = fCost * 0.85;}
else{fCostDiscount = fCost * 0.80;}
/* STARTING THE TAX SECTION */
if ((sState == "ga") || (sState == "GA") || (sState == "gA") || (sState == "Ga")){
fCostTax = fCostDiscount * 1.06;}
else if ((sState == "fl") || (sState == "FL") || (sState == "fL") || (sState == "Fl")){
fCostTax = fCostDiscount * 1.04;}
else if ((sState == "sc") || (sState == "SC") || (sState == "sC") || (sState == "Sc")){
fCostTax = fCostDiscount * 1.05;}
else if ((sState == "tn") || (sState == "TN") || (sState == "tN") || (sState == "Tn")){
fCostTax = fCostDiscount * 1.05;}
else if ((sState == "al") || (sState == "AL") || (sState == "aL") || (sState == "Al")){
fCostTax = fCostDiscount * 1.02;}
else{fCostTax = fCostDiscount * 1.00;}
/* Cost by State Counter */
if ((sState == "ga") || (sState == "GA") || (sState == "gA") || (sState == "Ga")){
CostGA = CostGA + fCostTax;}
else if ((sState == "fl") || (sState == "FL") || (sState == "fL") || (sState == "Fl")){
CostFL = CostFL + fCostTax;}
else if ((sState == "sc") || (sState == "SC") || (sState == "sC") || (sState == "Sc")){
CostSC = CostSC + fCostTax;}
else if ((sState == "tn") || (sState == "TN") || (sState == "tN") || (sState == "Tn")){
CostTN = CostTN + fCostTax;}
else if ((sState == "al") || (sState == "AL") || (sState == "aL") || (sState == "Al")){
CostAL = CostAL + fCostTax;}
else{CostOther = CostOther + fCostTax;}
/* Keeping track of Totals */
TotalCount += fGallonsNeeded;
TotalCost += fCostTax;
if (fCostTax > fRedundant){
fRedundant = fCostTax;
strcpy_s(sFirstHigh,sFirstName);
strcpy_s(sLastHigh,sLastName);}
return;} // End doCalc()
void sendOutput(void) {
cout << "********************************************************\n";
cout << " Acme Paint Shop - Single Customer Calculation \n";
cout << "********************************************************\n\n";
cout << "Customer Name: " << sFirstName << " " << sLastName << endl;
cout << "\nNumber of Gallons Needed: " << fGallonsNeeded << endl;
cout << "\nCost Before Discount: $" << setprecision(2) << fixed << fCost << endl;
cout << "\nCost After Discount: $" << setprecision(2) << fixed << fCostDiscount << endl;
cout << "\nCost With Tax: $" << setprecision(2) << fixed << fCostTax << endl;
return;}
void eodr(void) {
cout << "********************************************************\n";
cout << " Acme Paint Shop - End of Day Report \n";
cout << "********************************************************\n\n";
cout << "State # of Cans Total Cost After Discount/Tax\n";
cout << "GA " << setprecision(0) << fixed << CountGA << " $" << CostGA << endl;
cout << "FL " << setprecision(0) << fixed << CountFL << " $" << CostFL << endl;
cout << "SC " << setprecision(0) << fixed << CountSC << " $" << CostSC << endl;
cout << "TN " << setprecision(0) << fixed << CountTN << " $" << CostTN << endl;
cout << "AL " << setprecision(0) << fixed << CountAL << " $" << CostAL << endl;
cout << "Other " << setprecision(0) << fixed << CountOther << " $" << CostOther << endl;
cout << "________________________________________________________\n";
cout << "Grand Total " << TotalCount << " $" << TotalCost << endl;
cout << "\nCustomer With Highest Total After Tax: " << sFirstHigh << sLastHigh << endl;
cout << "Customer Total: $" << setprecision(2) << fixed << fRedundant << endl;
return;
}
void init(void) {
fHeight = 0.0; fWidth = 0.0; fLength = 0.0; fPaintSpace = 0.0; fGallonCost = 0.0;
fGallonsNeeded = 0.0; fArea = 0.0; fCost = 0.0;
fCostTax = 0.0; fCostDiscount = 0.0; fRedundant = 0.0; CountGA = 0.0; CountFL = 0.0;
CountSC = 0.0; CountTN = 0.0; CountAL = 0.0; CostGA = 0.0; CostFL = 0.0; CostSC = 0.0;
CostTN = 0.0; CostAL = 0.0; TotalCount = 0.0; TotalCost = 0.0; CountOther = 0.0; CostOther = 0.0;
}
|