C Business is booming for Luigi and Gina LaMota and their au
C++ Business is booming for Luigi and Gina LaMota and their automotive parts business. They would like you to help them keep track of the items that sell the best. To do this, you will need to write a program that will read data from a file and determine the item that produces the most revenue for a certain category. These best selling items and all the information pertaining to them will be written out to a file and delivered to Luigi and Gina. Output format for the file (headings, no actual results): ** Brakes ** Description: Price: Manufacturer: QtySold: Car: Brand: Model: Year: Material: ** Lights ** Description: Price: Manufacturer: QtySold: Car: Brand: Model: Year: Watts: ** Oil ** Description: Price: Manufacturer: QtySold: Weight: Type: Quarts: ** Tires ** Description: Price: Manufacturer: QtySold: Size: Warranty: // // data for this question: part list : \"Category\",\"Description\",\"Price\",\"Manufacturer\",\"QtySold\",\"CarBrand\",\"CarModel\",\"CarYear\",\"Material\",\"Watts\",\"Weight\",\"Type\",\"Quarts\",\"Size\",\"Warranty\" \"Oil\",\"Max Life Motor Oil\",\"30.99\",\"Valvoline\",\"44\",\"\",\"\",\"\",\"\",\"\",\"5W-20\",\"Synthetic Blend\",\"5\",\"\",\"\" \"Oil\",\"Mobil Super Motor Oil\",\"7.49\",\"Mobil\",\"322\",\"\",\"\",\"\",\"\",\"\",\"0W-20\",\"Synthetic\",\"1\",\"\",\"\" \"Brakes\",\"Thermoquiet Disc Brake Pads\",\"26.44\",\"Wagner\",\"76\",\"Honda\",\"Accord\",\"2012\",\"Ceramic\",\"\",\"\",\"\",\"\",\"\",\"\" \"Brakes\",\"Thermoquiet Disc Brake Pads\",\"23.39\",\"Wagner\",\"101\",\"Chrysler\",\"LeBaron\",\"2001\",\"Ceramic\",\"\",\"\",\"\",\"\",\"\",\"\" \"Brakes\",\"Quietcast Disc Brake Pads\",\"29.00\",\"Bosch\",\"203\",\"Nissan\",\"Quest\",\"2012\",\"Organic\",\"\",\"\",\"\",\"\",\"\",\"\" \"Oil\",\"Heavy Duty Motor Oil\",\"5.29\",\"Shell\",\"354\",\"\",\"\",\"\",\"\",\"\",\"10W-30\",\"Conventional\",\"1\",\"\",\"\" \"Oil\",\"Max Life Motor Oil\",\"30.99\",\"Valvoline\",\"44\",\"\",\"\",\"\",\"\",\"\",\"5W-20\",\"Synthetic Blend\",\"5\",\"\",\"\" \"Oil\",\"GTX Motor Oil\",\"30.99\",\"Castrol\",\"52\",\"\",\"\",\"\",\"\",\"\",\"5W-20\",\"Synthetic Blend\",\"5\",\"\",\"\" \"Tires\",\"Altimax\",\"89.99\",\"General\",\"14\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"P225/70R16\",\"60000\" \"Lights\",\"SilverStar Headlight Bulb\",\"26.99\",\"Sylvania\",\"342\",\"Honda\",\"Civic\",\"1993\",\"\",\"60\",\"\",\"\",\"\",\"\",\"\" \"Lights\",\"XtraVision Headlight Bulb\",\"14.99\",\"Sylvania\",\"533\",\"Ford\",\"Fiesta\",\"2014\",\"\",\"55\",\"\",\"\",\"\",\"\",\"\" \"Brakes\",\"Professional Disc Brake Pads\",\"44.56\",\"AC Delco\",\"123\",\"Infiniti\",\"J30\",\"2007\",\"Ceramic\",\"\",\"\",\"\",\"\",\"\",\"\" \"Brakes\",\"ProACT Premium Disc Brake Pads\",\"149.85\",\"Akebono\",\"99\",\"Lexus\",\"LS460\",\"2012\",\"Ceramic\",\"\",\"\",\"\",\"\",\"\",\"\" \"Oil\",\"Advanced Durability Motor Oil\",\"5.49\",\"Quaker State\",\"201\",\"\",\"\",\"\",\"\",\"\",\"10W-40\",\"Conventional\",\"1\",\"\",\"\" \"Oil\",\"Long Life Motor Oil\",\"4.99\",\"Pennzoil\",\"351\",\"\",\"\",\"\",\"\",\"\",\"10W-30\",\"Conventional\",\"1\",\"\",\"\" \"Oil\",\"High Mileage Motor Oil\",\"6.49\",\"Valvoline\",\"154\",\"\",\"\",\"\",\"\",\"\",\"10W-40\",\"Conventional\",\"1\",\"\",\"\" \"Brakes\",\"Professional Grade Disc Brake Pads\",\"39.15\",\"Raybestos\",\"45\",\"Ford\",\"Taurus\",\"1998\",\"Ceramic\",\"\",\"\",\"\",\"\",\"\",\"\" \"Brakes\",\"HiPerform Disc Brake Pads\",\"33.52\",\"BrakeBest\",\"144\",\"Jeep\",\"Wrangler\",\"2013\",\"Carbon Metallic\",\"\",\"\",\"\",\"\",\"\",\"\" \"Lights\",\"SilverStar ULTRA Headlight Bulb\",\"44.99\",\"Sylvania\",\"128\",\"Toyota\",\"Corolla\",\"2015\",\"\",\"60\",\"\",\"\",\"\",\"\",\"\" \"Lights\",\"TruVision Headlight Bulb\",\"32.99\",\"Bosch\",\"172\",\"Chevrolet\",\"Cavalier\",\"2004\",\"\",\"60\",\"\",\"\",\"\",\"\",\"\" \"Lights\",\"Headlight Bulb\",\"9.99\",\"EiKO\",\"621\",\"Nissan\",\"Altima\",\"2014\",\"\",\"60\",\"\",\"\",\"\",\"\",\"\" \"Oil\",\"Mobil 1 Motor Oil\",\"36.99\",\"Mobil\",\"39\",\"\",\"\",\"\",\"\",\"\",\"0W-20\",\"Synthetic\",\"5\",\"\",\"\" template: #include #include #include #include using namespace std; class Car { public: private: string brand; string model; int year; }; }; class Parts { } class Brakes : public Parts { } class Lights : public Parts { { class Oil : public Parts { { class Tires : public Parts { } int main() { //open the file from which to read the data //call a global function to find out how many objects of each type to create //create arrays to contain the necessary objects //global functions to read information from the file into the arrays of objects //find the best selling item for each category //close the file explicitly } // Notes: // // Example: // To create an array of \'cnt\' Books items, where \'cnt\' can only be determined at the time the program is run: // Books *booksList; // booksList = new Books[cnt]; // // // To go back and read from the beginning of the file that was already opened and read till the EOF // bookFile.clear(); // reset the EOF state // bookFile.seekg(0, ios::beg); // set pointer at the beginning of the file just displays the contents like in te given format
Solution
Solution: See the code below
--------------------------------------------
#include <iostream>
#include <fstream>
#include <cstring>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <sstream>
#include <algorithm>
using namespace std;
//Car class
class Car {
public:
Car()
{
brand=\"\";
model=\"\";
year=0;
}
Car(string brand, string model, int year)
{
this->brand=brand;
this->model=model;
this->year=year;
}
string getBrand()
{
return brand;
}
string getModel()
{
return model;
}
int getYear()
{
return year;
}
private:
string brand;
string model;
int year;
};
//Parts class
class Parts {
private:
string Description;
double Price;
string Manufacturer;
int QtySold;
public:
Parts()
{
Description=\"\";
Price=0.0;
Manufacturer=\"\";
QtySold=0;
}
Parts(string Description, double Price, string Manufacturer, int QtySold)
{
this->Description=Description;
this->Price=Price;
this->Manufacturer=Manufacturer;
this->QtySold=QtySold;
}
string getDescription()
{
return Description;
}
double getPrice()
{
return Price;
}
string getManufacturer()
{
return Manufacturer;
}
int getQtySold()
{
return QtySold;
}
};
//Brakes class
class Brakes : public Parts {
private:
Car car;
string Material;
public:
Brakes():Parts()
{
//car=0;
Material=\"\";
}
Brakes(string Description,double Price,string Manufacturer,int QtySold,string Material,Car car):Parts(Description, Price, Manufacturer, QtySold)
{
this->Material=Material;
this->car=car;
}
Car getCar()
{
return car;
}
string getMaterial()
{
return Material;
}
};
//Lights class
class Lights : public Parts {
private:
Car car;
int Watts;
public:
Lights():Parts()
{
//car=NULL;
Watts=0;
}
Lights(string Description,double Price,string Manufacturer,int QtySold,int Watts, Car car):Parts(Description, Price, Manufacturer, QtySold)
{
this->Watts=Watts;
this->car=car;
}
Car getCar()
{
return car;
}
int getWatts()
{
return Watts;
}
};
//Oil class
class Oil : public Parts {
private:
string Weight;
string Type;
int Quarts;
public:
Oil():Parts()
{
Weight=\"\";
Type=\"\";
Quarts=0;
}
Oil(string Description,double Price,string Manufacturer,int QtySold,string Weight,string Type,int Quarts):Parts(Description, Price, Manufacturer, QtySold)
{
this->Weight=Weight;
this->Type=Type;
this->Quarts=Quarts;
}
string getWeight()
{
return Weight;
}
string getType()
{
return Type;
}
int getQuarts()
{
return Quarts;
}
};
//Tires class
class Tires : public Parts {
private:
string Size;
int Warranty;
public:
Tires():Parts()
{
Size=\"\";
Warranty=0;
}
Tires(string Description,double Price,string Manufacturer,int QtySold,string Size,int Warranty):Parts(Description, Price, Manufacturer, QtySold)
{
this->Size=Size;
this->Warranty=Warranty;
}
string getSize()
{
return Size;
}
int getWarranty()
{
return Warranty;
}
};
//global data objects/variables
string* data; //array for input data
int totalParts=0; //total number of parts
Brakes* brakes; //array for Brakes objects
Oil* oil; //array for Oil objects
Lights* lights; //array for Lights objects
Tires* tires; //array for Tires objects
int BrakesCount=0; //Count of Brakes objects
int OilCount=0; //Count of Oil objects
int LightsCount=0; //Count of Lights objects
int TiresCount=0; //Count of Tires objects
//function to count differnt parts types
void countPartsTypes()
{
for(int i=0;i<totalParts;i++)
{
string line=data[i];
char *token=strtok(&line[0],\",\");
string Category(token);
if(Category.compare(\"\\\"Brakes\\\"\")==0)
{
BrakesCount++;
}
else if(Category.compare(\"\\\"Oil\\\"\")==0)
{
OilCount++;
}
else if(Category.compare(\"\\\"Lights\\\"\")==0)
{
LightsCount++;
}
else if(Category.compare(\"\\\"Tires\\\"\")==0)
{
TiresCount++;
}
}
}
//function to extract Brakes data
void ExtractBrakesData()
{
int j=0;
string Category;
string Description;
double Price;
string Manufacturer;
int QtySold;
//Car car;
string Material;
string brand;
string model;
int year;
for(int i=0;i<totalParts;i++)
{
string line=data[i];
int tokenno=0;
char *token=strtok(&line[0],\",\");
tokenno++;
while(token!=NULL)
{
string tokenValue(token);
tokenValue.erase(remove( tokenValue.begin(), tokenValue.end(), \'\\\"\' ),tokenValue.end());
switch(tokenno){
case 1:
Category=tokenValue;
//cout<<\"Category:\"<<Category<<endl;
break;
case 2:
if(Category.compare(\"Brakes\")==0){
Description=tokenValue;
//cout<<\"Desc:\"<<Description<<endl;
}
break;
case 3:
if(Category.compare(\"Brakes\")==0){
Price=atof(tokenValue.c_str());
//cout<<\"Price:\"<<Price<<endl;
}
break;
case 4:
if(Category.compare(\"Brakes\")==0){
Manufacturer=tokenValue;
//cout<<\"Manufacturer:\"<<Manufacturer<<endl;
}
break;
case 5:
if(Category.compare(\"Brakes\")==0){
QtySold=atoi(tokenValue.c_str());
//cout<<\"Qty Sold:\"<<QtySold<<endl;
}
break;
case 6:
if(Category.compare(\"Brakes\")==0){
brand=tokenValue;
//cout<<\"Car brand:\"<<brand<<endl;
}
break;
case 7:
if(Category.compare(\"Brakes\")==0){
model=tokenValue;
//cout<<\"Car model:\"<<model<<endl;
}
break;
case 8:
if(Category.compare(\"Brakes\")==0){
year=atoi(tokenValue.c_str());
//cout<<\"Car Year:\"<<year<<endl;
}
break;
case 9:
if(Category.compare(\"Brakes\")==0){
Material=tokenValue;
//cout<<\"Material:\"<<Material<<endl;
}
break;
}
token=strtok(NULL,\",\");
tokenno++;
}
if(Category.compare(\"Brakes\")==0 && j<BrakesCount){
Car car(brand, model,year);
Brakes brake(Description,Price,Manufacturer,QtySold,Material,car);
brakes[j]=brake;
j++;
}
}
}
//function to extract Lights data
void ExtractLightsData()
{
int j=0;
string Category;
string Description;
double Price;
string Manufacturer;
int QtySold;
int Watts;
string brand;
string model;
int year;
for(int i=0;i<totalParts;i++)
{
string line=data[i];
int tokenno=0;
char *token=strtok(&line[0],\",\");
tokenno++;
while(token!=NULL)
{
string tokenValue(token);
tokenValue.erase(remove( tokenValue.begin(), tokenValue.end(), \'\\\"\' ),tokenValue.end());
switch(tokenno){
case 1:
Category=tokenValue;
//cout<<\"Category:\"<<Category<<endl;
break;
case 2:
if(Category.compare(\"Lights\")==0){
Description=tokenValue;
//cout<<\"Desc:\"<<Description<<endl;
}
break;
case 3:
if(Category.compare(\"Lights\")==0){
Price=atof(tokenValue.c_str());
//cout<<\"Price:\"<<Price<<endl;
}
break;
case 4:
if(Category.compare(\"Lights\")==0){
Manufacturer=tokenValue;
//cout<<\"Manufacturer:\"<<Manufacturer<<endl;
}
break;
case 5:
if(Category.compare(\"Lights\")==0){
QtySold=atoi(tokenValue.c_str());
//cout<<\"Qty Sold:\"<<QtySold<<endl;
}
break;
case 6:
if(Category.compare(\"Lights\")==0){
brand=tokenValue;
//cout<<\"Car brand:\"<<brand<<endl;
}
break;
case 7:
if(Category.compare(\"Lights\")==0){
model=tokenValue;
//cout<<\"Car model:\"<<model<<endl;
}
break;
case 8:
if(Category.compare(\"Lights\")==0){
year=atoi(tokenValue.c_str());
//cout<<\"Car Year:\"<<year<<endl;
}
break;
case 10:
if(Category.compare(\"Lights\")==0){
Watts=atoi(tokenValue.c_str());
//cout<<\"Watts:\"<<Watts<<endl;
}
break;
}
token=strtok(NULL,\",\");
tokenno++;
}
//cout<<\"j:\"<<j<<endl;
if(Category.compare(\"Lights\")==0 && j<LightsCount){
Car car(brand, model,year);
Lights light(Description,Price,Manufacturer,QtySold,Watts,car);
lights[j]=light;
j++;
}
}
}
//function to extract Oil data
void ExtractOilData()
{
int j=0;
string Category;
string Description;
double Price;
string Manufacturer;
int QtySold;
string Weight;
string Type;
int Quarts;
for(int i=0;i<totalParts;i++)
{
string line=data[i];
int tokenno=0;
char *token=strtok(&line[0],\",\");
tokenno++;
while(token!=NULL)
{
string tokenValue(token);
tokenValue.erase(remove( tokenValue.begin(), tokenValue.end(), \'\\\"\' ),tokenValue.end());
switch(tokenno){
case 1:
Category=tokenValue;
//cout<<\"Category:\"<<Category<<endl;
break;
case 2:
if(Category.compare(\"Oil\")==0){
Description=tokenValue;
//cout<<\"Desc:\"<<Description<<endl;
}
break;
case 3:
if(Category.compare(\"Oil\")==0){
Price=atof(tokenValue.c_str());
//cout<<\"Price:\"<<Price<<endl;
}
break;
case 4:
if(Category.compare(\"Oil\")==0){
Manufacturer=tokenValue;
//cout<<\"Manufacturer:\"<<Manufacturer<<endl;
}
break;
case 5:
if(Category.compare(\"Oil\")==0){
QtySold=atoi(tokenValue.c_str());
//cout<<\"Qty Sold:\"<<QtySold<<endl;
}
break;
case 11:
if(Category.compare(\"Oil\")==0){
Weight=tokenValue;
//cout<<\"Weight:\"<<Weight<<endl;
}
break;
case 12:
if(Category.compare(\"Oil\")==0){
Type=tokenValue;
//cout<<\"Type:\"<<Quarts<<endl;
}
break;
case 13:
if(Category.compare(\"Oil\")==0){
Quarts=atoi(tokenValue.c_str());
//cout<<\"Quarts:\"<<Quarts<<endl;
}
break;
}
token=strtok(NULL,\",\");
tokenno++;
}
if(Category.compare(\"Oil\")==0 && j<OilCount){
Oil ol(Description,Price,Manufacturer,QtySold,Weight,Type,Quarts);
oil[j]=ol;
j++;
}
}
}
//function to extract Tires data
void ExtractTiresData()
{
int j=0;
string Category;
string Description;
double Price;
string Manufacturer;
int QtySold;
string Size;
int Warranty;
for(int i=0;i<totalParts;i++)
{
string line=data[i];
int tokenno=0;
char *token=strtok(&line[0],\",\");
tokenno++;
while(token!=NULL)
{
string tokenValue(token);
tokenValue.erase(remove( tokenValue.begin(), tokenValue.end(), \'\\\"\' ),tokenValue.end());
switch(tokenno){
case 1:
Category=tokenValue;
//cout<<\"Category:\"<<Category<<endl;
break;
case 2:
if(Category.compare(\"Tires\")==0){
Description=tokenValue;
//cout<<\"Desc:\"<<Description<<endl;
}
break;
case 3:
if(Category.compare(\"Tires\")==0){
Price=atof(tokenValue.c_str());
//cout<<\"Price:\"<<Price<<endl;
}
break;
case 4:
if(Category.compare(\"Tires\")==0){
Manufacturer=tokenValue;
//cout<<\"Manufacturer:\"<<Manufacturer<<endl;
}
break;
case 5:
if(Category.compare(\"Tires\")==0){
QtySold=atoi(tokenValue.c_str());
//cout<<\"Qty Sold:\"<<QtySold<<endl;
}
break;
case 14:
if(Category.compare(\"Tires\")==0){
Size=tokenValue;
//cout<<\"Size:\"<<Size<<endl;
}
break;
case 15:
if(Category.compare(\"Tires\")==0){
Warranty=atoi(tokenValue.c_str());
//cout<<\"Warranty:\"<<Warranty<<endl;
}
break;
}
token=strtok(NULL,\",\");
tokenno++;
}
if(Category.compare(\"Tires\")==0 && j<TiresCount){
Tires tire(Description,Price,Manufacturer,QtySold,Size,Warranty);
tires[j]=tire;
//cout<<\"tire:\"<<tire.getWarranty()<<endl;
j++;
}
}
}
//function to find best selling Brakes
Brakes FindBestSellingBrakes()
{
Brakes BestSellingBrakes=brakes[0];
double bestSellingPrice=BestSellingBrakes.getQtySold()*BestSellingBrakes.getPrice();
for(int i=1;i<BrakesCount;i++)
{
double sellingPrice=brakes[i].getQtySold()*brakes[i].getPrice();
if(bestSellingPrice < sellingPrice)
{
BestSellingBrakes=brakes[i];
}
}
return BestSellingBrakes;
}
//function to find best selling Lights
Lights FindBestSellingLights()
{
Lights BestSellingLights=lights[0];
double bestSellingPrice=BestSellingLights.getQtySold()*BestSellingLights.getPrice();
for(int i=1;i<LightsCount;i++)
{
double sellingPrice=lights[i].getQtySold()*lights[i].getPrice();
//cout<<\"light:\"<<sellingPrice<<endl;
if(bestSellingPrice < sellingPrice)
{
BestSellingLights=lights[i];
}
}
return BestSellingLights;
}
//function to find best selling Oil
Oil FindBestSellingOil()
{
Oil BestSellingOil=oil[0];
double bestSellingPrice=BestSellingOil.getQtySold()*BestSellingOil.getPrice();
for(int i=1;i<OilCount;i++)
{
double sellingPrice=oil[i].getQtySold()*oil[i].getPrice();
if(bestSellingPrice < sellingPrice)
{
BestSellingOil=oil[i];
}
}
return BestSellingOil;
}
//function to find best selling Tires
Tires FindBestSellingTires()
{
Tires BestSellingTires=tires[0];
double bestSellingPrice=BestSellingTires.getQtySold()*BestSellingTires.getPrice();
for(int i=1;i<TiresCount;i++)
{
double sellingPrice=tires[i].getQtySold()*tires[i].getPrice();
if(bestSellingPrice < sellingPrice)
{
BestSellingTires=tires[i];
}
}
return BestSellingTires;
}
//main function
int main() {
//open the file from which to read the data
ifstream infile(\"./data.txt\");
string line;
int lineno=0;
if(!infile)
{
cerr<<\"Error opening file. Exiting\"<<endl;
exit(1);
}
else
{
cout<<\"File opened!\"<<endl;
//count no. of records
while(getline(infile,line))
{
lineno++;
}
totalParts=lineno-1;
data=new string[totalParts];
lineno=0;
infile.clear();
infile.seekg(0,ios::beg);
while(getline(infile,line))
{
lineno++;
if(lineno>=2)
{
data[lineno-2]=line;
//cout<<data[lineno-2];
//cout<<line<<endl;
}
}
//call a global function to find out how many objects of each type to create
cout<<\"Counting Parts types...\"<<endl;
countPartsTypes();
//create arrays to contain the necessary objects
cout<<\"Brakes:\"<<BrakesCount<<endl;
brakes=new Brakes[BrakesCount];
cout<<\"Oil:\"<<OilCount<<endl;
oil=new Oil[OilCount];
cout<<\"Lights:\"<<LightsCount<<endl;
lights=new Lights[LightsCount];
cout<<\"Tires:\"<<TiresCount<<endl;
tires=new Tires[TiresCount];
//global functions to read information from the file into the arrays of objects
cout<<\"Extracting Brakes Data...\"<<endl;
ExtractBrakesData();
cout<<\"Extracting Lights Data...\"<<endl;
ExtractLightsData();
cout<<\"Extracting Oil Data...\"<<endl;
ExtractOilData();
cout<<\"Extracting Tires Data...\"<<endl;
ExtractTiresData();
//find the best selling item for each category
ofstream outfile(\"./output.txt\");
if(outfile){
cout<<\"Writing to output file...\"<<endl;
Brakes brake=FindBestSellingBrakes();
outfile<<\"** Brakes ** Description: \"<<brake.getDescription()
<<\" Price: \"<<brake.getPrice()
<<\" Manufacturer: \"<<brake.getManufacturer()
<<\" QtySold: \"<<brake.getQtySold()
<<\" Car: Brand: \"<<brake.getCar().getBrand()
<<\" Model: \"<<brake.getCar().getModel()
<<\" Year: \"<<brake.getCar().getYear()
<<\" Material: \"<<brake.getMaterial()<<endl;
Lights light=FindBestSellingLights();
outfile<<\"** Lights ** Description: \"<<light.getDescription()
<< \" Price: \"<<light.getPrice()
<< \" Manufacturer: \"<<light.getManufacturer()
<< \" QtySold: \"<<light.getQtySold()
<< \" Car: Brand: \"<<light.getCar().getBrand()
<< \" Model: \"<<light.getCar().getModel()
<< \" Year: \"<<light.getCar().getYear()
<< \" Watts: \"<<light.getWatts()<<endl;
Oil oil=FindBestSellingOil();
outfile<<\"** Oil ** Description: \"<<oil.getDescription()
<<\" Price: \"<<oil.getPrice()
<<\" Manufacturer: \"<<oil.getManufacturer()
<<\" QtySold: \"<<oil.getQtySold()
<<\" Weight: \"<<oil.getWeight()
<<\" Type: \"<<oil.getType()
<<\" Quarts: \"<<oil.getQuarts()
<<endl;
Tires tire=FindBestSellingTires();
outfile<<\"** Tires ** Description: \"<<tire.getDescription()
<<\" Price: \"<<tire.getPrice()
<<\" Manufacturer: \"<<tire.getManufacturer()
<<\" QtySold: \"<<tire.getQtySold()
<<\" Size: \"<<tire.getSize()
<<\" Warranty: \"<<tire.getWarranty()
<<endl;
}
}
//close the file explicitly
infile.close();
}
--------------------------------------
Data file: data.txt
-----------------------------------------
\"Category\",\"Description\",\"Price\",\"Manufacturer\",\"QtySold\",\"CarBrand\",\"CarModel\",\"CarYear\",\"Material\",\"Watts\",\"Weight\",\"Type\",\"Quarts\",\"Size\",\"Warranty\"
\"Oil\",\"Max Life Motor Oil\",\"30.99\",\"Valvoline\",\"44\",\"\",\"\",\"\",\"\",\"\",\"5W-20\",\"Synthetic Blend\",\"5\",\"\",\"\"
\"Oil\",\"Mobil Super Motor Oil\",\"7.49\",\"Mobil\",\"322\",\"\",\"\",\"\",\"\",\"\",\"0W-20\",\"Synthetic\",\"1\",\"\",\"\"
\"Brakes\",\"Thermoquiet Disc Brake Pads\",\"26.44\",\"Wagner\",\"76\",\"Honda\",\"Accord\",\"2012\",\"Ceramic\",\"\",\"\",\"\",\"\",\"\",\"\"
\"Brakes\",\"Thermoquiet Disc Brake Pads\",\"23.39\",\"Wagner\",\"101\",\"Chrysler\",\"LeBaron\",\"2001\",\"Ceramic\",\"\",\"\",\"\",\"\",\"\",\"\"
\"Brakes\",\"Quietcast Disc Brake Pads\",\"29.00\",\"Bosch\",\"203\",\"Nissan\",\"Quest\",\"2012\",\"Organic\",\"\",\"\",\"\",\"\",\"\",\"\"
\"Oil\",\"Heavy Duty Motor Oil\",\"5.29\",\"Shell\",\"354\",\"\",\"\",\"\",\"\",\"\",\"10W-30\",\"Conventional\",\"1\",\"\",\"\"
\"Oil\",\"Max Life Motor Oil\",\"30.99\",\"Valvoline\",\"44\",\"\",\"\",\"\",\"\",\"\",\"5W-20\",\"Synthetic Blend\",\"5\",\"\",\"\"
\"Oil\",\"GTX Motor Oil\",\"30.99\",\"Castrol\",\"52\",\"\",\"\",\"\",\"\",\"\",\"5W-20\",\"Synthetic Blend\",\"5\",\"\",\"\"
\"Tires\",\"Altimax\",\"89.99\",\"General\",\"14\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"P225/70R16\",\"60000\"
\"Lights\",\"SilverStar Headlight Bulb\",\"26.99\",\"Sylvania\",\"342\",\"Honda\",\"Civic\",\"1993\",\"\",\"60\",\"\",\"\",\"\",\"\",\"\"
\"Lights\",\"XtraVision Headlight Bulb\",\"14.99\",\"Sylvania\",\"533\",\"Ford\",\"Fiesta\",\"2014\",\"\",\"55\",\"\",\"\",\"\",\"\",\"\"
\"Brakes\",\"Professional Disc Brake Pads\",\"44.56\",\"AC Delco\",\"123\",\"Infiniti\",\"J30\",\"2007\",\"Ceramic\",\"\",\"\",\"\",\"\",\"\",\"\"
\"Brakes\",\"ProACT Premium Disc Brake Pads\",\"149.85\",\"Akebono\",\"99\",\"Lexus\",\"LS460\",\"2012\",\"Ceramic\",\"\",\"\",\"\",\"\",\"\",\"\"
\"Oil\",\"Advanced Durability Motor Oil\",\"5.49\",\"Quaker State\",\"201\",\"\",\"\",\"\",\"\",\"\",\"10W-40\",\"Conventional\",\"1\",\"\",\"\"
\"Oil\",\"Long Life Motor Oil\",\"4.99\",\"Pennzoil\",\"351\",\"\",\"\",\"\",\"\",\"\",\"10W-30\",\"Conventional\",\"1\",\"\",\"\"
\"Oil\",\"High Mileage Motor Oil\",\"6.49\",\"Valvoline\",\"154\",\"\",\"\",\"\",\"\",\"\",\"10W-40\",\"Conventional\",\"1\",\"\",\"\"
\"Brakes\",\"Professional Grade Disc Brake Pads\",\"39.15\",\"Raybestos\",\"45\",\"Ford\",\"Taurus\",\"1998\",\"Ceramic\",\"\",\"\",\"\",\"\",\"\",\"\"
\"Brakes\",\"HiPerform Disc Brake Pads\",\"33.52\",\"BrakeBest\",\"144\",\"Jeep\",\"Wrangler\",\"2013\",\"Carbon Metallic\",\"\",\"\",\"\",\"\",\"\",\"\"
\"Lights\",\"SilverStar ULTRA Headlight Bulb\",\"44.99\",\"Sylvania\",\"128\",\"Toyota\",\"Corolla\",\"2015\",\"\",\"60\",\"\",\"\",\"\",\"\",\"\"
\"Lights\",\"TruVision Headlight Bulb\",\"32.99\",\"Bosch\",\"172\",\"Chevrolet\",\"Cavalier\",\"2004\",\"\",\"60\",\"\",\"\",\"\",\"\",\"\"
\"Lights\",\"Headlight Bulb\",\"9.99\",\"EiKO\",\"621\",\"Nissan\",\"Altima\",\"2014\",\"\",\"60\",\"\",\"\",\"\",\"\",\"\"
\"Oil\",\"Mobil 1 Motor Oil\",\"36.99\",\"Mobil\",\"39\",\"\",\"\",\"\",\"\",\"\",\"0W-20\",\"Synthetic\",\"5\",\"\",\"\"
------------------------------------------------
Outfile: output.txt
------------------------------------
** Brakes ** Description: HiPerform Disc Brake Pads Price: 33.52 Manufacturer: BrakeBest QtySold: 144 Car: Brand: Jeep Model: Wrangler Year: 2013 Material: Carbon Metallic
** Lights ** Description: SilverStar Headlight Bulb Price: 26.99 Manufacturer: Sylvania QtySold: 342 Car: Brand: Honda Model: Civic Year: 1993 Watts: 60
** Oil ** Description: Mobil 1 Motor Oil Price: 36.99 Manufacturer: Mobil QtySold: 39 Weight: 0W-20 Type: Synthetic Quarts: 5
** Tires ** Description: Altimax Price: 89.99 Manufacturer: General QtySold: 14 Size: P225/70R16 Warranty: 60000
--------------------------------------













