If anyone can help me with this application, I\'d be forevergrateful. I\'ve been
ID: 3615257 • Letter: I
Question
If anyone can help me with this application, I'd be forevergrateful. I've been working at it for days but I have very littleexpertise with C++, so I'm making very little progress. It wouldtake someone with C++ expertise probably half an hour or less tocomplete.Here is the link for the PDF file with all the info about theproject: https://docs.google.com/fileview?id=0B7s4eP7JuZBVM2EwZDYwYzktMDA2OS00MzhkLTg1Y2MtNzM4ZDY5MWE2ODZl&hl=en
Here is the link for the PDF file with all the info about theproject: https://docs.google.com/fileview?id=0B7s4eP7JuZBVM2EwZDYwYzktMDA2OS00MzhkLTg1Y2MtNzM4ZDY5MWE2ODZl&hl=en
Explanation / Answer
Contents of Store.h
#ifndef STORE_H #define STORE_H #include <string> using namespace std;
class GrocItem { public: string name; //name of product int quantity; //number of items purchased float reg_price; //retial price float sale_price; // sale price bool onsale; //on sale or no enum taxCat {ALCOHOL, FOOD, GENERAL, MEDICINE}; //taxcategory
public: //friend std::istream& getline(std::istream&,GrocItem&); //constructor GrocItem(); GrocItem::GrocItem(string n, int q, float rp, float sp, boolos, taxCat tc) { name = n; quantity = q; reg_price = rp; sale_price = sp; taxCat = tc; }
//mutator functions /* void setName(string n) { name = n;}
void setQty(int q) { quantity = q;}
void setRegPrice(float rp) { reg_price = rp;}
void setSalePrice(float sp) { sale_price = sp;} void setSaleStatus(bool os) {
void setTaxCat(taxCat tc); //{ taxCat = tc;} */ //accessor functions string getName() const { return name;}
int getQty() const {return quantity;}
float getRegPrice() const { return reg_price;}
float getSalePrice() const { return sale_price;}
bool getSaleStatus() const { return onsale;}
void getTax(taxCat tc) const; //{ return taxCat;}
//void readFile(array, int);
}; #endif
//static constants const double tax_alcohol = .08; const double tax_food = .05; const double tax_general = .07; const double tax_medicine = .04;
__________________________________________________________________
Contents of functions.cpp
#include "store.h" #include <iostream> #include <fstream> #include <string> #include <istream> using namespace std;
//constructor /*GrocItem::GrocItem(string n, int q, float rp, float sp, boolos, taxCat tc); { name = n; quantity = q; reg_price = rp; sale_price = sp; taxCat = tc; } */
void readFile(GrocItem objects[], int size) { fstream inputFile; const int FILESIZE = 51; char filename[FILESIZE]; cout << "What is the name of the product file: "; cin >> filename; inputFile.open(filename, ios::in);
for (int count = 0; count < size; count++) { while (!inputFile.eof()) { inputFile.getline(string name,objects[count].getName()); inputFile.getline(quantity, objects[count].getQty()); inputFile.getline(reg_price,objects[count].getRegPrice()); inputFile.getline(sale_price,objects[count].getSalePrice()); inputFile.getline(onsale,objects[count].getSaleStatus()); inputFile.getline(taxCat, objects[count].getTax()); } } }
___________________________________________________________
Contents of Project.cpp
#include <iostream> #include <string> #include "store.h" using namespace std;
int main() { const int MAX_OBJECTS = 20; GrocItem product[MAX_OBJECTS];
//function readFile(product, MAX_OBJECTS); }
#ifndef STORE_H #define STORE_H #include <string> using namespace std;
class GrocItem { public: string name; //name of product int quantity; //number of items purchased float reg_price; //retial price float sale_price; // sale price bool onsale; //on sale or no enum taxCat {ALCOHOL, FOOD, GENERAL, MEDICINE}; //taxcategory
public: //friend std::istream& getline(std::istream&,GrocItem&); //constructor GrocItem(); GrocItem::GrocItem(string n, int q, float rp, float sp, boolos, taxCat tc) { name = n; quantity = q; reg_price = rp; sale_price = sp; taxCat = tc; }
//mutator functions /* void setName(string n) { name = n;}
void setQty(int q) { quantity = q;}
void setRegPrice(float rp) { reg_price = rp;}
void setSalePrice(float sp) { sale_price = sp;} void setSaleStatus(bool os) {
void setTaxCat(taxCat tc); //{ taxCat = tc;} */ //accessor functions string getName() const { return name;}
int getQty() const {return quantity;}
float getRegPrice() const { return reg_price;}
float getSalePrice() const { return sale_price;}
bool getSaleStatus() const { return onsale;}
void getTax(taxCat tc) const; //{ return taxCat;}
//void readFile(array, int);
}; #endif
//static constants const double tax_alcohol = .08; const double tax_food = .05; const double tax_general = .07; const double tax_medicine = .04;
__________________________________________________________________
Contents of functions.cpp
#include "store.h" #include <iostream> #include <fstream> #include <string> #include <istream> using namespace std;
//constructor /*GrocItem::GrocItem(string n, int q, float rp, float sp, boolos, taxCat tc); { name = n; quantity = q; reg_price = rp; sale_price = sp; taxCat = tc; } */
void readFile(GrocItem objects[], int size) { fstream inputFile; const int FILESIZE = 51; char filename[FILESIZE]; cout << "What is the name of the product file: "; cin >> filename; inputFile.open(filename, ios::in);
for (int count = 0; count < size; count++) { while (!inputFile.eof()) { inputFile.getline(string name,objects[count].getName()); inputFile.getline(quantity, objects[count].getQty()); inputFile.getline(reg_price,objects[count].getRegPrice()); inputFile.getline(sale_price,objects[count].getSalePrice()); inputFile.getline(onsale,objects[count].getSaleStatus()); inputFile.getline(taxCat, objects[count].getTax()); } } }
___________________________________________________________
Contents of Project.cpp
#include <iostream> #include <string> #include "store.h" using namespace std;
int main() { const int MAX_OBJECTS = 20; GrocItem product[MAX_OBJECTS];
//function readFile(product, MAX_OBJECTS); } #include "store.h" #include <iostream> #include <fstream> #include <string> #include <istream> using namespace std;
//constructor /*GrocItem::GrocItem(string n, int q, float rp, float sp, boolos, taxCat tc); { name = n; quantity = q; reg_price = rp; sale_price = sp; taxCat = tc; } */
void readFile(GrocItem objects[], int size) { fstream inputFile; const int FILESIZE = 51; char filename[FILESIZE]; cout << "What is the name of the product file: "; cin >> filename; inputFile.open(filename, ios::in);
for (int count = 0; count < size; count++) { while (!inputFile.eof()) { inputFile.getline(string name,objects[count].getName()); inputFile.getline(quantity, objects[count].getQty()); inputFile.getline(reg_price,objects[count].getRegPrice()); inputFile.getline(sale_price,objects[count].getSalePrice()); inputFile.getline(onsale,objects[count].getSaleStatus()); inputFile.getline(taxCat, objects[count].getTax()); } } }
___________________________________________________________
Contents of Project.cpp
#include <iostream> #include <string> #include "store.h" using namespace std;
int main() { const int MAX_OBJECTS = 20; GrocItem product[MAX_OBJECTS];
//function readFile(product, MAX_OBJECTS); } #include <iostream> #include <string> #include "store.h" using namespace std;
int main() { const int MAX_OBJECTS = 20; GrocItem product[MAX_OBJECTS];
//function readFile(product, MAX_OBJECTS); }