Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "product.h"
- #include <sstream>
- int main()
- {
- Product Inventory[100];
- int itemline = 0;
- double subTotal = 0.0;
- fstream filestr ("inventory.txt", fstream::in | fstream::out);
- int PLU;
- string name;
- int type;
- double priceper;
- double inventory;
- if (filestr.is_open())
- {
- while(!(filestr.eof()) && (itemline < 100))
- {
- filestr >> PLU >> name >> type >> priceper >> inventory;
- Inventory[itemline].setPLU(PLU);
- Inventory[itemline].setName(name);
- Inventory[itemline].setType(type);
- Inventory[itemline].setPricePer(priceper);
- Inventory[itemline].setInventory(inventory);
- Inventory[itemline].setexists(true);
- itemline++;
- cout << Inventory[itemline];
- cout << "older" << Inventory[itemline-1];
- }
- filestr.close();
- }
- else cout << "Unable to open file";
- cout << "closed";
- for(int i =0 ; i!= itemline; i++)
- {
- cout << Inventory[i];
- }
- int printcount = 0;
- ofstream outfile ("output.txt");
- if(outfile.is_open())
- {
- while(printcount != itemline && Inventory[printcount].exists())
- {
- outfile << Inventory[printcount];
- //outfile.flush();
- printcount++;
- }
- outfile.close();
- }
- return 0;
- }
- output
- 4101 BRAEBURN_REG 1 0.99 101.5
- older4101 BRAEBURN_REG 1 0.99 101.5
- 4021 DELICIOUS_GDN_REG 1 0.89 94.2
- older4021 DELICIOUS_GDN_REG 1 0.89 94.2
- 4020 DELICIOUS_GLDN_LG 1 1.09 84.2
- older4020 DELICIOUS_GLDN_LG 1 1.09 84.2
- 4015 DELICIOUS_RED_REG 1 1.19 75.3
- older4015 DELICIOUS_RED_REG 1 1.19 75.3
- 4016 DELICIOUS_RED_LG 1 1.29 45.6
- older4016 DELICIOUS_RED_LG 1 1.29 45.6
- 4167 DELICIOUS_RED_SM 1 0.89 35.4
- older4167 DELICIOUS_RED_SM 1 0.89 35.4
- 4124 EMPIRE 1 1.14 145.2
- older4124 EMPIRE 1 1.14 145.2
- 4129 FUJI_REG 1 1.05 154.5
- older4129 FUJI_REG 1 1.05 154.5
- 4131 FUJI_X-LGE 1 1.25 164.1
- older4131 FUJI_X-LGE 1 1.25 164.1
- 4135 GALA_LGE 1 1.35 187.7
- older4135 GALA_LGE 1 1.35 187.7
- 4133 GALA_REG 1 1.45 145.2
- older4133 GALA_REG 1 1.45 145.2
- 4139 GRANNY_SMITH_REG 1 1.39 198.2
- older4139 GRANNY_SMITH_REG 1 1.39 198.2
- 4017 GRANNY_SMITH_LGE 1 1.49 176.5
- older4017 GRANNY_SMITH_LGE 1 1.49 176.5
- 3115 PEACHES 1 2.09 145.5
- older3115 PEACHES 1 2.09 145.5
- 4011 BANANAS 1 0.49 123.2
- older4011 BANANAS 1 0.49 123.2
- 4383 MINNEOLAS 1 0.79 187.3
- older4383 MINNEOLAS 1 0.79 187.3
- 3144 TANGERINES 1 1.19 135.5
- older3144 TANGERINES 1 1.19 135.5
- 4028 STRAWBERRIES_PINT 0 0.99 104
- older4028 STRAWBERRIES_PINT 0 0.99 104
- 4252 STRAWBERRIES_HALF_CASE 0 3.99 53
- older4252 STRAWBERRIES_HALF_CASE 0 3.99 53
- 4249 STRAWBERRIES_FULL_CASE 0 7.49 67
- older4249 STRAWBERRIES_FULL_CASE 0 7.49 67
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- older94011 ORGANIC_BANANAS 1 0.99 56.3
- closed94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
- 94011 ORGANIC_BANANAS 1 0.99 56.3
Add Comment
Please, Sign In to add comment