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 192 193 194 195 196 197 198 199 200 201
|
void groceriesCalc()
{
grocery Customers[1024];
int T = 0;
int TotalDiscount = 0;
string customer;
for(int i = 0;i < 1024;i++)
{
cout << "Enter Customer " << i + 1 << "'s name: ";
cin.getline(Customers[i].Customer,256);
cin.getline(Customers[i].Customer,256);
customer = Customers[i].Customer;
if(customer == "Quit")
{
break;
}
cout << "Enter final price tag: $";
cin >> Customers[i].PriceTag;
if(i < 10 && Customers[i].PriceTag > 200)
{
Customers[i].Discount += 50;
TotalDiscount += 50;
}
else if(Customers[i].PriceTag > 200)
{
Customers[i].Discount += 5;
TotalDiscount += 5;
}
T++;
}
cout << endl << endl;
for(int i = 0;i < T;i++)
{
cout << "Customer " << i + 1 << "'s name: " << Customers[i].Customer << endl;
cout << "Customer Sub-Total: $" << Customers[i].PriceTag << endl;
cout << "Customer Discount: $" << Customers[i].Discount << endl;
Customers[i].FPriceTag = Customers[i].PriceTag - Customers[i].Discount;
cout << "Customer Total: $" << Customers[i].FPriceTag << endl;
cout << "--------------------------------------------" << endl;
}
cout << "Store's expense on discounts: $" << TotalDiscount << endl;
}
void libraryCalc()
{
library Browser[256];
int Discount_F = 0,Discount_S = 0,Discount_B = 0,B = 0,C = 0; // $40 and $60 Discounts and the bonus %5. Number of Books sold and Customers
double temp = 0;
double total = 0;
string customer;
char ttemp[256];
for(int i = 0;i < 256;i++)
{
cout << "Customer " << i + 1 << "'s Name: ";
cin.getline(Browser[i].Customer,256);
cin.getline(Browser[i].Customer,256);
customer = Browser[i].Customer;
if(customer == "Quit")
{
break;
}
cout << "Enter a negative in book price to quit." << endl;
for(int j = 0;j < 256;j++)
{
cout << "Enter book " << j + 1 << "'s title: ";
cin.getline(ttemp,256);
if(j > 0)
{
cin.getline(ttemp,256);
}
Browser[i].BookName[j] = *ttemp;
cout << "Enter book price: ";
cin >> Browser[i].BookPrice[j];
if(Browser[i].BookPrice[j] < 0)
{
break;
}
if(Browser[i].BookPrice[j] > 60) // $60 discounts
{
temp = Browser[i].BookPrice[j] * 0.2;
Browser[i].Discount += (Browser[i].BookPrice[j] - temp);
total += Browser[i].Discount;
Browser[i].Discount_S++;
Discount_S++;
}
else if(Browser[i].BookPrice[j] > 40 && Browser[i].BookPrice[j] < 60) //$40 Discounts
{
temp = Browser[i].BookPrice[j] * 0.1;
Browser[i].Discount += (Browser[i].BookPrice[j] - temp);
total += Browser[i].Discount;
Browser[i].Discount_F++;
Discount_F++;
}
Browser[i].PriceTag += Browser[i].BookPrice[j];
B++;
}
if(Browser[i].PriceTag > 200)
{
temp = Browser[i].PriceTag * .05;
Browser[i].FPriceTag = temp;
total += (Browser[i].PriceTag - temp);
Browser[i].Discount_S++;
Discount_S++;
}
else
{
Browser[i].FPriceTag = Browser[i].PriceTag;
}
Browser[i].books++;
C++;
}
cout << endl << endl;
for(int i = 0;i < C;i++)
{
cout << "Customer " << i + 1 << "'s name is: " << Browser[i].Customer << endl;
cout << Browser[i].Customer << " bought " << Browser[i].books << " books!" << endl;
for(int j = 0;j < Browser[i].books;j++)
{
cout << Browser[i].BookName[j] << "\t" << "$" << Browser[i].BookPrice << endl;
}
cout << "Amount of $60 discounts: " << Browser[i].Discount_S << endl;
cout << "Amount of $40 discounts: " << Browser[i].Discount_F << endl;
cout << "Amount of bonus > $200 discounts: " << Browser[i].Discount_B << endl;
cout << "Sub-Total: $" << Browser[i].PriceTag << endl;
cout << "Total Discounts: $" << Browser[i].Discount << endl;
cout << "Total: $" << Browser[i].FPriceTag << endl;
cout << "----------------------------------------------------" << endl;
}
cout << endl << "Amount of people with $60 discounts: " << Discount_S << endl;
cout << "Amount of people with $40 discounts: " << Discount_F << endl;
cout << "Amount of people with bonus discounts: " << Discount_B << endl;
cout << "Number of books sold today: " << B << endl;
cout << "Store's expenses on discounts: $" << total << endl;
}
int main(int nNumberofArgs,char* pszArgs[])
{
char answer;
cout << "Welcome to the multi-tasking discount machine!" << endl;
for(;;)
{
cout << "F for Factory scenario, G for Groceries scenario, and L for Library scenario" << endl;
cout << "Enter Q to quit: ";
cin >> answer;
switch(answer)
{
case 'f':
case 'F':
cout << "Enter 'Quit' to quit" << endl;
factoryCalc();
cout << endl;
break;
case 'g':
case 'G':
cout << "Enter 'Quit' to quit" << endl;
groceriesCalc();
cout << endl;
break;
case 'l':
case 'L':
cout << "Enter 'Quit' to quit" << endl;
libraryCalc();
cout << endl;
break;
case 'q':
case 'Q':
cout << "Thank you for using this application, have a nice day!" << endl;
system("PAUSE");
return 0;
default:
cout << "Please enter 'F','G', or 'L'" << endl;
}
}
return 0;
}
|