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 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
|
#include "Includes.h"
extern void main(void);
extern void main()
{
{
cPublication *oPublication;
oPublication = new cPublication;
sTypes *Type;
Type = new sTypes;
int iChoice;
//cout << "Publication constructor up...\n";
cout << "\nAre you interested in ordering books or magazines? \n";
cout << "\t 1 - Book\n";
cout << "\t 2 - Magazine\n";
cin >> iChoice;
cout << "You will be ordering a ";
switch(iChoice)
{
case 1:
*Type = book;
cout << "books\n";
break;
case 2:
*Type = magazine;
cout << "magazines\n";
break;
}
cout <<"\n";
{
cMagazine *oMagazine;
oMagazine = new cMagazine;
oMagazine->SetiArticles(20);
int iArticles = oMagazine->GetiArticles();
//cout<<"\nMagazine constructor up...\n\n";
//cout<< "\ncMagazine instantiated as having "<< iArticles <<" articles in the magazine\n";
cout<<"\nHow many in-depth articles would you like to see in your favorite guitar magazine?\n";
cin>>iArticles;
if(iArticles < 6)
cout<< "Not a big reader eh?\n";
else
cout<< "Alright! You must have a lot of useless knowledge up there!\n";
delete oMagazine;
{
cBook *oBook;
oBook = new cBook;
oBook->SetiChapters(12);
int iChapters = oBook->GetiChapters();
//cout<<"\nBook constructor up...\n";
//cout << "\nThere are " << iChapters << " chapters as instantiated\n";
cout << "\nHow many chapters in your favorite book?\n";
cin >>iChapters;
cout<< "\nYour book has "<< iChapters << " chapters in it?\n";
if (iChapters <10)
cout << "\nShort attention deficit?\n";
else
cout << "\nI like novels too!\n";
delete oBook;
{
cBPrice *oBPrice;
oBPrice = new cBPrice;
oBPrice->SetiNumBooks(1);
int iNumBooks = oBPrice->GetiNumBooks();
double iBPrice = 20.00;
cout << "To summarize, your favorite book has "<< iChapters <<" chapter(s) in it, and your favorite magazine should have "<< iArticles <<" articles in it.\n\n"<<endl;
cout << "Our distribution center has just the specialty books and magazines your niche market looks for!\nHow many books can I order for you?\n"<<endl;
cout << "Books run $20, magazines run $6\n"<<endl;
cin >> iNumBooks;
cout<<endl;
oBPrice->SetiNumBooks(iNumBooks);
double iBSum = iBPrice * iNumBooks;
double iTax = .05;
double iBSubTotal = iBSum * iTax;
double iBTotal = iBSubTotal + iBSum;
cout << "The total of your book purchases will be $" << iBSum << " dollars plus $"<< iBSubTotal << " tax, coming to $"<< iBTotal<<endl<<endl;
/*NEED TO GO ONLINE TO FIND ALGORITHYM FOR NO ROUNDING!!!!!
for ( places = 0; places <=2; places++ )
{
cout.precision(places) << " The total of your book purchases will be " << iSum << " dollars plus "<< iSubTotal << " tax, coming to "<< iTotal<<endl;
}*/
oBPrice->SetiNumMagazines(1);
int iNumMagazines = oBPrice->GetiNumMagazines();
double iMPrice = 6.00;
cout << "\nHow many Magazines can I order for you?\n";
cin >> iNumMagazines;
cout<<endl;
oBPrice->SetiNumMagazines(iNumMagazines);
double iMSum = iMPrice * iNumMagazines;
double iMSubTotal = iMSum * iTax;
oBPrice->SetiMTotal(0.00);
double iMTotal = iMSubTotal + iMSum;
oBPrice->SetiMTotal(iMTotal);
iMTotal = oBPrice->GetiMTotal();
cout << "The total of your Magazine purchases will be $" << iMSum << " dollars plus $"<< iMSubTotal << " tax, coming to $"<< iMTotal<<endl;
oBPrice->SetiSubTotalBoth(1.00);
double iSubTotalBoth = iMSum + iBSum;
oBPrice->SetiSubTotalBoth(iSubTotalBoth);
iSubTotalBoth = oBPrice->GetiSubTotalBoth();
cout << "Total for your order: " << iSubTotalBoth<<endl<<endl;
oBPrice->SetiTaxBoth(.05);
double iTaxBoth = iSubTotalBoth * iTax;
oBPrice->SetiTaxBoth(iTaxBoth);
iTaxBoth = oBPrice->GetiTaxBoth();
cout << "Tax on your books and magazines purchase is $" <<iTaxBoth<<endl;
oBPrice ->SetiDisplayTotalBoth(1.00);
double iDisplayTotalBoth = iTaxBoth + iSubTotalBoth;
oBPrice ->SetiDisplayTotalBoth(iDisplayTotalBoth);
iDisplayTotalBoth = oBPrice->GetiDisplayTotalBoth();
cout << "Your total with tax is $" << iDisplayTotalBoth<<endl<<endl;
cout << "Make payment to Kevin Schuth, oh, and he likes cash!!!!\n";
#define BUF_SIZE 101
#define IN_FILE "ReceiptData.dat"
#define OUT_FILE "SalesLogFile.dat"
{
ifstream ifInputFile;
ofstream ofOutputFile;
char sBuffer[BUF_SIZE];
bool bDataExists(true);
int iTotal = 0;
ifInputFile.open( IN_FILE, ios::in );
if( ifInputFile.is_open() != 1 )
{
cout << "File " << IN_FILE << " could not be opened!" << endl;
cout << "Exiting program, good bye." << endl;
}
else
{
cout << endl << endl;
while( bDataExists == true )
{
ifInputFile.getline( sBuffer, 101 );
if( ifInputFile.eof() == 1 )
{
bDataExists = false;
}
else
{
cout << sBuffer << endl;
iTotal += atoi(sBuffer);
}
}
ifInputFile.close();
cout << endl << endl;
}
ofOutputFile.open(OUT_FILE, ios::out);
if( ofOutputFile.is_open() == 1 )
{
cout<<"Writing Sales Log"<< endl << endl;
//iNumBooks = oBPrice->GetiNumBooks();
//iNumMagazines = oBPrice->GetiNumMagazines();
iDisplayTotalBoth = oBPrice->GetiDisplayTotalBoth();
//ofOutputFile<< "The total books ordered is " << iNumBooks << endl;
//ofOutputFile<< "The total magazines ordered is " << iNumMagazines << endl;
ofOutputFile<< "The total of your order is $" << iDisplayTotalBoth << endl;
ofOutputFile<< "Thank you for your purchase"<< endl;
ofOutputFile<< "Schuth Publication Distributors"<<endl;
ofOutputFile<< "Kevin J Schuth"<<endl;
}
ofOutputFile.close();
cout << "Sales Log closed, have a day!" << endl;
};
delete oBook;
delete oMagazine;
delete oBPrice;
delete oPublication;
}
}
}
}
return;
};
|