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 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
|
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
float CalcDiscount(int &mon, float &bTax);
float CalcSalesTax(char &code, float &Total);
float CalcShipping(int &totalWt, float &sTotal);
void GetSalesInfo(int &accountNum, int &month, int &day, int &year, char
&cCode)
{
cout << "Please Enter your account number: ";
cin >> accountNum;
cout << "Please Enter the Sales Date. " << endl;
cout << "Enter Month: ";
cin >> month;
cout << "Enter day: ";
cin >> day;
cout << "Enter year: ";
cin >> year;
cout << "Please Enter the County Code: ";
cin >> cCode;
};
void getItemInfo(float& bTax, int&totalWt)//get the prices and wt
{
cout<<"\nEnter information on an item? Y or N:";
char choice;//declares choice in local function only
float price;//declares price in local function only
int weight;//declares weight variable in local function only
cin>>choice;//read input choice
while(choice=='Y')//while user enters yes then get the price and weight
{
cout<<"\nPlease enter the price of the item";//outputs price
cin>>price;//reads price input
cout<<"\nPlease enter the weight of the item";//outputs weight
cin>>weight;//reads the weight from user
bTax+=price;//calculates price to total
totalWt+=weight;//calculates total weight
cout<<"\nEnter information on an item? Y or N";
}
return;
}
void OutputInvoice(int accountNum, char &cCode, int day, int year, int
month, float bTax, float discount, float taxTotal, float shipTotal,
float totalDue)
{
cout << "ACCOUNT NUMBER" << setw(20) << "COUNTY" << endl;
cout << setw(9) << accountNum;
cout << setw(29);
switch (cCode)
{
case 'o':
cout << "Orange County";
break;
case 'O':
cout << "Orange County";
break;
case 's':
cout << "San Diego county";
break;
case 'S':
cout << "San Diego county";
break;
case 'l':
cout << "LA County";
break;
case 'L':
cout << "LA County";
break;
default:
cout << "Invalid input";
break;
}
cout << endl << endl;
cout << "DATE OF SALE: " << month << "/" << day << "/" << year;
cout << endl << endl << endl;
cout << setw(20) << left << "SALE AMOUNT:" << "$" << setw(11) << right
<< bTax << endl;
cout << setw(20) << left << "DISCOUNT:" << "$" << setw(11) << right <<
discount << endl;
cout << setw(20) << left << "SALES TAX:" << "$" << setw(11) << right <<
taxTotal << endl;
cout << setw(20) << left << "SHIPPING:" << "$" << setw(11) << right <<
shipTotal << endl;
cout << setw(20) << left << "TOTAL DUE:" << "$" << setw(11) << right <<
totalDue;
};
int main()
{
int accountNum;
int month;
int day;
int year;
char cCode;
float bTax;
int weight;
int totalWt;
float discount;
float taxTotal;
float aDisTotal;
float shipTotal;
float sTotal;
float totalDue;
GetSalesInfo(accountNum, month, day, year, cCode);
getItemInfo(bTax,totalWt);
cout << fixed << setprecision(2);
discount = CalcDiscount(month, bTax);
aDisTotal = bTax - discount;
taxTotal = CalcSalesTax(cCode, aDisTotal);
shipTotal = CalcShipping(totalWt, sTotal);
totalDue = aDisTotal + taxTotal + shipTotal;
OutputInvoice(accountNum, cCode, day, year, month, bTax, discount,
taxTotal, shipTotal, totalDue);
return 0;
}
float CalcDiscount(int &mon, float &bTax)
{
float one = .05;
float two = .1;
float three = .15;
if (mon <= 5)
{
return bTax *one;
}
else if (mon <= 8)
{
return bTax *two;
}
else
return bTax *three;
}
float CalcSalesTax(char &code, float &total)
{
float one = .0775;
float two = .0825;
float three = .08;
switch (code)
{
case 'o':
return one *total;
break;
case 'O':
return one *total;
break;
case 's':
return two *total;
break;
case 'S':
return two *total;
break;
case 'l':
return three *total;
break;
case 'L':
return three *total;
break;
default:
cout << "Invalid input";
break;
}
}
float CalcShipping(int &totalWt, float &sTotal)
{
if (totalWt <= 25)
{
return 5.00;
}
else if (totalWt <= 50)
{
return (totalWt - 25) *.1 + 5.00;
}
else if (totalWt > 50)
{
return (totalWt - 25) *.07 + 5.00;
}
}
|